Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
22cf6f3
mobile friendly debug view
dotku Jan 9, 2017
3900775
优化Router代码 顺便问一下,url中静态变量是不是在没有设置merge_extra_vars时应该不可用,路由应该判断为错误
cnbailian Jan 10, 2017
c7a7c1a
Route增加option参数,效果为选择所在模块
cnbailian Jan 10, 2017
5c4df0c
修改架构函数为 构造方法
hooklife Jan 10, 2017
a01c434
改进Model类的has和hasWhere方法
liu21st Feb 9, 2017
532173e
优化HasOne的has方法
liu21st Feb 9, 2017
76d7804
readme更新
liu21st Feb 9, 2017
0d48f4a
改进Query类的find方法的缓存机制
liu21st Feb 9, 2017
1e1f36e
改进Query类缓存更新 修正Connection类一处可能的错误
liu21st Feb 9, 2017
2c0ee2f
改进软删除
liu21st Feb 9, 2017
ea9fe74
默认关闭session的安全传输,此选项仅能在HTTPS下设置开启
iiQi Feb 13, 2017
59c6ec2
Merge pull request #469 from mineyang/master
liu21st Feb 13, 2017
a414d12
配置参数名只分割为两部分
iiQi Feb 13, 2017
21834f7
Merge branch 'master' into bugfix3
hooklifecoplit Feb 13, 2017
d4c9a93
Merge pull request #438 from hooklife/bugfix3
liu21st Feb 13, 2017
342448d
Merge pull request #436 from cnbailian/master
liu21st Feb 13, 2017
af2b5d4
Merge pull request #471 from mineyang/master
liu21st Feb 13, 2017
0fa7dd3
Merge pull request #432 from dotku/master
liu21st Feb 13, 2017
bc1bd1b
改进Model类delete方法
liu21st Feb 13, 2017
c917ad1
改进Query类缓存机制
liu21st Feb 14, 2017
855124a
改进分页类
liu21st Feb 15, 2017
e8df221
修复 WHERE IN / NOT IN 型查询条件为空导致的 sql 语法错误
hldh214 Feb 15, 2017
94f5759
Merge pull request #477 from hldh214/patch-4
liu21st Feb 15, 2017
56008a2
修正Route类parseUrlPath方法
liu21st Feb 16, 2017
140a3f8
Merge branch 'master' of https://github.com/top-think/framework
liu21st Feb 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ThinkPHP5在保持快速开发和大道至简的核心理念不变的同时,PH

> ThinkPHP5的运行环境要求PHP5.4以上。

详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5)
详细开发文档参考 [ThinkPHP5完全开发手册](http://www.kancloud.cn/manual/thinkphp5) 以及[ThinkPHP5入门系列教程](http://www.kancloud.cn/special/thinkphp5_quickstart)

## 目录结构

Expand Down
2 changes: 1 addition & 1 deletion convention.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
// 是否自动开启 SESSION
'auto_start' => true,
'httponly' => true,
'secure' => true,
'secure' => false,
],

// +----------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions lang/zh-cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@
'invalid request' => '非法请求',
'bind attr has exists' => '模型的属性已经存在',
'relation data not exists' => '关联数据不存在',
'relation not support' => '关联不支持',
];
6 changes: 3 additions & 3 deletions library/think/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function has($name, $range = '')
return isset(self::$config[$range][strtolower($name)]);
} else {
// 二维数组设置和获取支持
$name = explode('.', $name);
$name = explode('.', $name, 2);
return isset(self::$config[$range][strtolower($name[0])][$name[1]]);
}
}
Expand All @@ -111,7 +111,7 @@ public static function get($name = null, $range = '')
return isset(self::$config[$range][$name]) ? self::$config[$range][$name] : null;
} else {
// 二维数组设置和获取支持
$name = explode('.', $name);
$name = explode('.', $name, 2);
$name[0] = strtolower($name[0]);
return isset(self::$config[$range][$name[0]][$name[1]]) ? self::$config[$range][$name[0]][$name[1]] : null;
}
Expand All @@ -135,7 +135,7 @@ public static function set($name, $value = null, $range = '')
self::$config[$range][strtolower($name)] = $value;
} else {
// 二维数组设置和获取支持
$name = explode('.', $name);
$name = explode('.', $name, 2);
self::$config[$range][strtolower($name[0])][$name[1]] = $value;
}
return;
Expand Down
2 changes: 1 addition & 1 deletion library/think/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Controller
protected $beforeActionList = [];

/**
* 架构函数
* 构造方法
* @param Request $request Request对象
* @access public
*/
Expand Down
25 changes: 7 additions & 18 deletions library/think/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
protected static $initialized = [];

/**
* 架构函数
* 构造方法
* @access public
* @param array|object $data 数据
*/
Expand Down Expand Up @@ -1081,7 +1081,7 @@ public function delete()

// 删除条件
$pk = $this->getPk();
if (isset($this->data[$pk])) {
if (is_string($pk) && isset($this->data[$pk])) {
$where = [$pk => $this->data[$pk]];
} elseif (!empty($this->updateWhere)) {
$where = $this->updateWhere;
Expand Down Expand Up @@ -1426,16 +1426,11 @@ public static function useGlobalScope($use)
*/
public static function has($relation, $operator = '>=', $count = 1, $id = '*')
{
$model = new static();
$relation = $model->$relation();
if ($relation instanceof HasMany) {
if (is_array($operator) || $operator instanceof \Closure) {
return $relation->hasWhere($operator);
}
return $relation->has($operator, $count, $id);
} else {
return $relation;
$relation = (new static())->$relation();
if (is_array($operator) || $operator instanceof \Closure) {
return $relation->hasWhere($operator);
}
return $relation->has($operator, $count, $id);
}

/**
Expand All @@ -1447,13 +1442,7 @@ public static function has($relation, $operator = '>=', $count = 1, $id = '*')
*/
public static function hasWhere($relation, $where = [])
{
$model = new static();
$relation = $model->$relation();
if ($relation instanceof HasMany) {
return $relation->hasWhere($where);
} else {
return $relation;
}
return (new static())->$relation()->hasWhere($where);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions library/think/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,15 @@ public function toArray()
{
try {
$total = $this->total();
} catch (Exception $e) {
} catch (\DomainException $e) {
$total = null;
}

return [
'total' => $total,
'per_page' => $this->listRows(),
'current_page' => $this->currentPage(),
'data' => $this->items->toArray()
'data' => $this->items->toArray(),
];
}

Expand Down
2 changes: 1 addition & 1 deletion library/think/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Request
protected $isCheckCache;

/**
* 架构函数
* 构造函数
* @access protected
* @param array $options 参数
*/
Expand Down
2 changes: 1 addition & 1 deletion library/think/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Response
protected $content = null;

/**
* 架构函数
* 构造函数
* @access public
* @param mixed $data 输出数据
* @param int $code
Expand Down
9 changes: 5 additions & 4 deletions library/think/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ protected static function registerRules($rules, $type = '*')
public static function rule($rule, $route = '', $type = '*', $option = [], $pattern = [])
{
$group = self::getGroup('name');

if (!is_null($group)) {
// 路由分组
$option = array_merge(self::getGroup('option'), $option);
Expand Down Expand Up @@ -308,6 +309,9 @@ protected static function setRule($rule, $route, $type = '*', $option = [], $pat
$suffix = isset($option['ext']) ? $option['ext'] : null;
self::name($name, [$key, $vars, self::$domain, $suffix]);
}
if (isset($option['modular'])) {
$route = $option['modular'] . '/' . $route;
}
if ($group) {
if ('*' != $type) {
$option['method'] = $type;
Expand Down Expand Up @@ -1166,7 +1170,7 @@ private static function checkRule($rule, $route, $url, $pattern, $option, $depr)
$len1 = substr_count($url, '|');
$len2 = substr_count($rule, '/');
// 多余参数是否合并
$merge = !empty($option['merge_extra_vars']) ? true : false;
$merge = !empty($option['merge_extra_vars']);
if ($merge && $len1 > $len2) {
$url = str_replace('|', $depr, $url);
$url = implode('|', explode($depr, $url, $len2 + 1));
Expand Down Expand Up @@ -1277,9 +1281,6 @@ private static function parseUrlPath($url)
} elseif (strpos($url, '/')) {
// [模块/控制器/操作]
$path = explode('/', $url);
} elseif (false !== strpos($url, '=')) {
// 参数1=值1&参数2=值2...
parse_str($url, $var);
} else {
$path = [$url];
}
Expand Down
2 changes: 1 addition & 1 deletion library/think/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Template
protected $storage;

/**
* 架构函数
* 构造函数
* @access public
*/
public function __construct(array $config = [])
Expand Down
2 changes: 1 addition & 1 deletion library/think/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Validate
protected $batch = false;

/**
* 架构函数
* 构造函数
* @access public
* @param array $rules 验证规则
* @param array $message 验证提示信息
Expand Down
2 changes: 1 addition & 1 deletion library/think/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class View
protected $replace = [];

/**
* 架构函数
* 构造函数
* @access public
* @param array $engine 模板引擎参数
* @param array $replace 字符串替换参数
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class File extends Driver
];

/**
* 架构函数
* 构造函数
* @param array $options
*/
public function __construct($options = [])
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/Lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Lite extends Driver
];

/**
* 架构函数
* 构造函数
* @access public
*
* @param array $options
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/Memcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Memcache extends Driver
];

/**
* 架构函数
* 构造函数
* @param array $options 缓存参数
* @access public
* @throws \BadFunctionCallException
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Memcached extends Driver
];

/**
* 架构函数
* 构造函数
* @param array $options 缓存参数
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Redis extends Driver
];

/**
* 架构函数
* 构造函数
* @param array $options 缓存参数
* @access public
*/
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Sqlite extends Driver
];

/**
* 架构函数
* 构造函数
* @param array $options 缓存参数
* @throws \BadFunctionCallException
* @access public
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/Wincache.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Wincache extends Driver
];

/**
* 架构函数
* 构造函数
* @param array $options 缓存参数
* @throws \BadFunctionCallException
* @access public
Expand Down
2 changes: 1 addition & 1 deletion library/think/cache/driver/Xcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Xcache extends Driver
];

/**
* 架构函数
* 构造函数
* @param array $options 缓存参数
* @access public
* @throws \BadFunctionCallException
Expand Down
2 changes: 1 addition & 1 deletion library/think/controller/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class Rest
];

/**
* 架构函数 取得模板对象实例
* 构造函数 取得模板对象实例
* @access public
*/
public function __construct()
Expand Down
2 changes: 1 addition & 1 deletion library/think/controller/Yar.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class Yar
{

/**
* 架构函数
* 构造函数
* @access public
*/
public function __construct()
Expand Down
4 changes: 2 additions & 2 deletions library/think/db/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class Builder
protected $deleteSql = 'DELETE FROM %TABLE% %USING% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';

/**
* 架构函数
* 构造函数
* @access public
* @param Connection $connection 数据库连接对象实例
* @param Query $query 数据库查询对象实例
Expand Down Expand Up @@ -379,7 +379,7 @@ protected function parseWhereItem($field, $val, $rule = '', $options = [], $bind
} else {
$zone = implode(',', $this->parseValue($value, $field));
}
$whereStr .= $key . ' ' . $exp . ' (' . $zone . ')';
$whereStr .= $key . ' ' . $exp . ' (' . (empty($zone) ? "''" : $zone) . ')';
}
} elseif (in_array($exp, ['NOT BETWEEN', 'BETWEEN'])) {
// BETWEEN 查询
Expand Down
6 changes: 3 additions & 3 deletions library/think/db/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ abstract class Connection
protected $bind = [];

/**
* 架构函数 读取数据库配置信息
* 构造函数 读取数据库配置信息
* @access public
* @param array $config 数据库配置数组
*/
Expand Down Expand Up @@ -365,8 +365,8 @@ public function query($sql, $bind = [], $master = false, $pdo = false)
$this->bind = $bind;
}

//释放前次的查询结果
if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) {
// 释放前次的查询结果
if (!empty($this->PDOStatement)) {
$this->free();
}

Expand Down
Loading