升级基础框架,Tp到5.0.7

This commit is contained in:
邹景立 2017-03-06 12:02:57 +08:00
parent 9a775341b3
commit d31f5def04
77 changed files with 670 additions and 269 deletions

42
composer.lock generated
View File

@ -17,7 +17,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/ivanlanin/pclzip/19dd1de9d3f5fc4d7d70175b4c344dee329f45fd.zip",
"url": "https://files.phpcomposer.com/files/ivanlanin/pclzip/19dd1de9d3f5fc4d7d70175b4c344dee329f45fd.zip",
"reference": "19dd1de9d3f5fc4d7d70175b4c344dee329f45fd",
"shasum": ""
},
@ -54,7 +54,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/qiniu/php-sdk/b91653485e36b4797d7a302cc86c49695e47a642.zip",
"url": "https://files.phpcomposer.com/files/qiniu/php-sdk/b91653485e36b4797d7a302cc86c49695e47a642.zip",
"reference": "b91653485e36b4797d7a302cc86c49695e47a642",
"shasum": ""
},
@ -97,16 +97,16 @@
},
{
"name": "topthink/framework",
"version": "v5.0.6",
"version": "v5.0.7",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "a3a37e6cfad132d5b02ffff8f23a4abc565f7928"
"reference": "bcf64f19f4fadbff6c8503891689ff7e6f2fe9a3"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/framework/a3a37e6cfad132d5b02ffff8f23a4abc565f7928.zip",
"reference": "a3a37e6cfad132d5b02ffff8f23a4abc565f7928",
"url": "https://files.phpcomposer.com/files/top-think/framework/bcf64f19f4fadbff6c8503891689ff7e6f2fe9a3.zip",
"reference": "bcf64f19f4fadbff6c8503891689ff7e6f2fe9a3",
"shasum": ""
},
"require": {
@ -144,7 +144,7 @@
"orm",
"thinkphp"
],
"time": "2017-02-07 09:39:59"
"time": "2017-02-25 02:51:57"
},
{
"name": "topthink/think-captcha",
@ -156,7 +156,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-captcha/0c55455df26a1626a60d0dc35d2d89002b741d44.zip",
"url": "https://files.phpcomposer.com/files/top-think/think-captcha/0c55455df26a1626a60d0dc35d2d89002b741d44.zip",
"reference": "0c55455df26a1626a60d0dc35d2d89002b741d44",
"shasum": ""
},
@ -192,7 +192,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-helper/ed64408cdc4cdbd390365ba0906d208b987af520.zip",
"url": "https://files.phpcomposer.com/files/top-think/think-helper/ed64408cdc4cdbd390365ba0906d208b987af520.zip",
"reference": "ed64408cdc4cdbd390365ba0906d208b987af520",
"shasum": ""
},
@ -228,7 +228,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-installer/4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d.zip",
"url": "https://files.phpcomposer.com/files/top-think/think-installer/4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d.zip",
"reference": "4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d",
"shasum": ""
},
@ -261,16 +261,16 @@
},
{
"name": "topthink/think-mongo",
"version": "v1.5",
"version": "v1.6",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-mongo.git",
"reference": "2dd7ecae965cd3a6e5cc99f3db7c63353dae4cf3"
"reference": "1c6d29f58bd7caa8da088c167b4e65ddac621588"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-mongo/2dd7ecae965cd3a6e5cc99f3db7c63353dae4cf3.zip",
"reference": "2dd7ecae965cd3a6e5cc99f3db7c63353dae4cf3",
"url": "https://files.phpcomposer.com/files/top-think/think-mongo/1c6d29f58bd7caa8da088c167b4e65ddac621588.zip",
"reference": "1c6d29f58bd7caa8da088c167b4e65ddac621588",
"shasum": ""
},
"type": "library",
@ -291,20 +291,20 @@
}
],
"description": "mongodb driver for thinkphp5",
"time": "2017-02-06 06:05:55"
"time": "2017-02-13 07:17:51"
},
{
"name": "topthink/think-queue",
"version": "v1.1.2",
"version": "v1.1.3",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-queue.git",
"reference": "503c5b809585ca60cba9485a233aa8be4b22c990"
"reference": "07480c36381344bef9db9c9bbe3de28005a839d3"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-queue/503c5b809585ca60cba9485a233aa8be4b22c990.zip",
"reference": "503c5b809585ca60cba9485a233aa8be4b22c990",
"url": "https://files.phpcomposer.com/files/top-think/think-queue/07480c36381344bef9db9c9bbe3de28005a839d3.zip",
"reference": "07480c36381344bef9db9c9bbe3de28005a839d3",
"shasum": ""
},
"require": {
@ -336,7 +336,7 @@
}
],
"description": "The ThinkPHP5 Queue Package",
"time": "2016-12-01 04:29:39"
"time": "2017-02-28 08:07:37"
},
{
"name": "zoujingli/wechat-php-sdk",
@ -348,7 +348,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/zoujingli/wechat-php-sdk/12759d48867aab14e6b66be81a5b5afe223a0476.zip",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/12759d48867aab14e6b66be81a5b5afe223a0476.zip",
"reference": "12759d48867aab14e6b66be81a5b5afe223a0476",
"shasum": ""
},

View File

@ -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)
## 目录结构

View File

@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
define('THINK_VERSION', '5.0.6');
define('THINK_VERSION', '5.0.7');
define('THINK_START_TIME', microtime(true));
define('THINK_START_MEM', memory_get_usage());
define('EXT', '.php');

View File

@ -2,7 +2,7 @@
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// | Copyright (c) 2006-2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

View File

@ -206,7 +206,7 @@ return [
// 是否自动开启 SESSION
'auto_start' => true,
'httponly' => true,
'secure' => true,
'secure' => false,
],
// +----------------------------------------------------------------------

View File

@ -64,4 +64,5 @@ return [
'invalid request' => '非法请求',
'bind attr has exists' => '模型的属性已经存在',
'relation data not exists' => '关联数据不存在',
'relation not support' => '关联不支持',
];

View File

@ -87,7 +87,7 @@ class Config
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]]);
}
}
@ -111,7 +111,7 @@ class Config
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;
}
@ -135,7 +135,7 @@ class Config
self::$config[$range][strtolower($name)] = $value;
} else {
// 二维数组设置和获取支持
$name = explode('.', $name);
$name = explode('.', $name, 2);
self::$config[$range][strtolower($name[0])][$name[1]] = $value;
}
return;

View File

@ -40,7 +40,7 @@ class Controller
protected $beforeActionList = [];
/**
* 架构函数
* 构造方法
* @param Request $request Request对象
* @access public
*/

View File

@ -369,8 +369,9 @@ class Loader
if (isset(self::$instance[$guid])) {
return self::$instance[$guid];
}
if (strpos($name, '\\')) {
$class = $name;
if (false !== strpos($name, '\\')) {
$class = $name;
$module = Request::instance()->module();
} else {
if (strpos($name, '/')) {
list($module, $name) = explode('/', $name, 2);
@ -404,8 +405,9 @@ class Loader
*/
public static function controller($name, $layer = 'controller', $appendSuffix = false, $empty = '')
{
if (strpos($name, '\\')) {
$class = $name;
if (false !== strpos($name, '\\')) {
$class = $name;
$module = Request::instance()->module();
} else {
if (strpos($name, '/')) {
list($module, $name) = explode('/', $name);
@ -440,8 +442,9 @@ class Loader
if (isset(self::$instance[$guid])) {
return self::$instance[$guid];
}
if (strpos($name, '\\')) {
$class = $name;
if (false !== strpos($name, '\\')) {
$class = $name;
$module = Request::instance()->module();
} else {
if (strpos($name, '/')) {
list($module, $name) = explode('/', $name);

View File

@ -14,7 +14,7 @@ namespace think;
use InvalidArgumentException;
use think\db\Query;
use think\Exception\ValidateException;
use think\model\Collection;
use think\model\Collection as ModelCollection;
use think\model\Relation;
use think\model\relation\BelongsTo;
use think\model\relation\BelongsToMany;
@ -109,7 +109,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
protected static $initialized = [];
/**
* 架构函数
* 构造方法
* @access public
* @param array|object $data 数据
*/
@ -290,9 +290,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
// 标记字段更改
if (isset($this->data[$name]) && is_scalar($this->data[$name]) && is_scalar($value) && 0 !== strcmp($this->data[$name], $value)) {
if (!isset($this->data[$name])) {
$this->change[] = $name;
} elseif (!isset($this->data[$name]) || $value != $this->data[$name]) {
} elseif (is_scalar($value) && is_scalar($this->data[$name]) && 0 !== strcmp($this->data[$name], $value)) {
$this->change[] = $name;
} elseif (!is_object($value) && $value != $this->data[$name]) {
$this->change[] = $name;
}
// 设置数据对象属性
@ -508,7 +510,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$value = json_decode($value, true);
break;
case 'array':
$value = is_null($value) ? [] : json_decode($value, true);
$value = empty($value) ? [] : json_decode($value, true);
break;
case 'object':
$value = empty($value) ? new \stdClass() : json_decode($value);
@ -624,7 +626,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
/**
* 转换子模型对象
* @access protected
* @param Model|Collection $model
* @param Model|ModelCollection $model
* @param $visible
* @param $hidden
* @param $key
@ -663,7 +665,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
foreach ($data as $key => $val) {
if ($val instanceof Model || $val instanceof Collection) {
if ($val instanceof Model || $val instanceof ModelCollection) {
// 关联模型对象
$item[$key] = $this->subToArray($val, $visible, $hidden, $key);
} elseif (is_array($val) && reset($val) instanceof Model) {
@ -712,14 +714,14 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
/**
* 转换当前模型数据集为数据集对象
* @access public
* @param array|Collection $collection 数据集
* @return Collection
* @param array|\think\Collection $collection 数据集
* @return \think\Collection
*/
public function toCollection($collection)
{
if ($this->resultSetType) {
if ('collection' == $this->resultSetType) {
$collection = new Collection($collection);
$collection = new ModelCollection($collection);
} elseif (false !== strpos($this->resultSetType, '\\')) {
$class = $this->resultSetType;
$collection = new $class($collection);
@ -1081,7 +1083,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 删除条件
$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;
@ -1426,16 +1428,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
*/
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);
}
/**
@ -1447,13 +1444,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
*/
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);
}
/**
@ -1493,7 +1484,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$closure = $relation;
$relation = $key;
}
if (strpos($relation, '.')) {
if (is_array($relation)) {
$subRelation = $relation;
$relation = $key;
} elseif (strpos($relation, '.')) {
list($relation, $subRelation) = explode('.', $relation, 2);
}
$method = Loader::parseName($relation, 1, false);
@ -1519,7 +1513,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$closure = $relation;
$relation = $key;
}
if (strpos($relation, '.')) {
if (is_array($relation)) {
$subRelation = $relation;
$relation = $key;
} elseif (strpos($relation, '.')) {
list($relation, $subRelation) = explode('.', $relation, 2);
}
$relation = Loader::parseName($relation, 1, false);
@ -1545,7 +1542,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$closure = $relation;
$relation = $key;
}
if (strpos($relation, '.')) {
if (is_array($relation)) {
$subRelation = $relation;
$relation = $key;
} elseif (strpos($relation, '.')) {
list($relation, $subRelation) = explode('.', $relation, 2);
}
$relation = Loader::parseName($relation, 1, false);
@ -1569,10 +1569,16 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
if ($relation instanceof \Closure) {
$closure = $relation;
$relation = $key;
} elseif (is_string($key)) {
$name = $relation;
$relation = $key;
}
$relation = Loader::parseName($relation, 1, false);
$count = $this->$relation()->relationCount($result, $closure);
$result->setAttr(Loader::parseName($relation) . '_count', $count);
if (!isset($name)) {
$name = Loader::parseName($relation) . '_count';
}
$result->setAttr($name, $count);
}
}

View File

@ -341,7 +341,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
{
try {
$total = $this->total();
} catch (Exception $e) {
} catch (\DomainException $e) {
$total = null;
}
@ -349,7 +349,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J
'total' => $total,
'per_page' => $this->listRows(),
'current_page' => $this->currentPage(),
'data' => $this->items->toArray()
'data' => $this->items->toArray(),
];
}

View File

@ -120,7 +120,7 @@ class Request
protected $isCheckCache;
/**
* 构函数
* 函数
* @access protected
* @param array $options 参数
*/
@ -633,7 +633,7 @@ class Request
if (true === $name) {
// 获取包含文件上传信息的数组
$file = $this->file();
$data = array_merge($this->param, $file);
$data = is_array($file) ? array_merge($this->param, $file) : $this->param;
return $this->input($data, '', $default, $filter);
}
return $this->input($this->param, $name, $default, $filter);
@ -688,7 +688,7 @@ class Request
{
if (empty($this->post)) {
$content = $this->input;
if (empty($_POST) && 'application/json' == $this->contentType()) {
if (empty($_POST) && false !== strpos($this->contentType(), 'application/json')) {
$this->post = (array) json_decode($content, true);
} else {
$this->post = $_POST;
@ -713,7 +713,7 @@ class Request
{
if (is_null($this->put)) {
$content = $this->input;
if ('application/json' == $this->contentType()) {
if (false !== strpos($this->contentType(), 'application/json')) {
$this->put = (array) json_decode($content, true);
} else {
parse_str($content, $this->put);
@ -1357,7 +1357,11 @@ class Request
{
$contentType = $this->server('CONTENT_TYPE');
if ($contentType) {
list($type) = explode(';', $contentType);
if (strpos($contentType, ';')) {
list($type) = explode(';', $contentType);
} else {
$type = $contentType;
}
return trim($type);
}
return '';
@ -1523,13 +1527,13 @@ class Request
}
}
// 自动缓存功能
$key = '__URL__';
$key = md5($this->host()) . '__URL__';
} elseif (strpos($key, '|')) {
list($key, $fun) = explode('|', $key);
}
// 特殊规则替换
if (false !== strpos($key, '__')) {
$key = str_replace(['__MODULE__', '__CONTROLLER__', '__ACTION__', '__URL__'], [$this->module, $this->controller, $this->action, md5($this->url())], $key);
$key = str_replace(['__MODULE__', '__CONTROLLER__', '__ACTION__', '__URL__', ''], [$this->module, $this->controller, $this->action, md5($this->url())], $key);
}
if (false !== strpos($key, ':')) {

View File

@ -40,7 +40,7 @@ class Response
protected $content = null;
/**
* 构函数
* 函数
* @access public
* @param mixed $data 输出数据
* @param int $code

View File

@ -232,6 +232,7 @@ class Route
public static function rule($rule, $route = '', $type = '*', $option = [], $pattern = [])
{
$group = self::getGroup('name');
if (!is_null($group)) {
// 路由分组
$option = array_merge(self::getGroup('option'), $option);
@ -304,8 +305,12 @@ class Route
}
$vars = self::parseVar($rule);
if (isset($name)) {
$key = $group ? $group . ($rule ? '/' . $rule : '') : $rule;
self::name($name, [$key, $vars, self::$domain]);
$key = $group ? $group . ($rule ? '/' . $rule : '') : $rule;
$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) {
@ -447,7 +452,8 @@ class Route
$vars = self::parseVar($key);
$item[] = ['rule' => $key, 'route' => $route, 'var' => $vars, 'option' => $options, 'pattern' => $patterns];
// 设置路由标识
self::name($route, [$name . ($key ? '/' . $key : ''), $vars, self::$domain]);
$suffix = isset($options['ext']) ? $options['ext'] : null;
self::name($route, [$name . ($key ? '/' . $key : ''), $vars, self::$domain, $suffix]);
}
self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern];
}
@ -827,7 +833,7 @@ class Route
// 分隔符替换 确保路由定义使用统一的分隔符
$url = str_replace($depr, '|', $url);
if (strpos($url, '|') && isset(self::$rules['alias'][strstr($url, '|', true)])) {
if (isset(self::$rules['alias'][$url]) || isset(self::$rules['alias'][strstr($url, '|', true)])) {
// 检测路由别名
$result = self::checkRouteAlias($request, $url, $depr);
if (false !== $result) {
@ -1126,8 +1132,8 @@ class Route
|| (isset($option['ajax']) && !$option['ajax'] && $request->isAjax()) // 非Ajax检测
|| (isset($option['pjax']) && $option['pjax'] && !$request->isPjax()) // Pjax检测
|| (isset($option['pjax']) && !$option['pjax'] && $request->isPjax()) // 非Pjax检测
|| (isset($option['ext']) && false === stripos('|' . $option['ext'] . '|', $request->ext() ? '|' . $request->ext() . '|' : '')) // 伪静态后缀检测
|| (isset($option['deny_ext']) && false !== stripos('|' . $option['deny_ext'] . '|', $request->ext() ? '|' . $request->ext() . '|' : ''))
|| (isset($option['ext']) && false === stripos('|' . $option['ext'] . '|', '|' . $request->ext() . '|')) // 伪静态后缀检测
|| (isset($option['deny_ext']) && false !== stripos('|' . $option['deny_ext'] . '|', '|' . $request->ext() . '|'))
|| (isset($option['domain']) && !in_array($option['domain'], [$_SERVER['HTTP_HOST'], self::$subDomain])) // 域名检测
|| (isset($option['https']) && $option['https'] && !$request->isSsl()) // https检测
|| (isset($option['https']) && !$option['https'] && $request->isSsl()) // https检测
@ -1164,7 +1170,7 @@ class Route
$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));
@ -1275,9 +1281,6 @@ class Route
} elseif (strpos($url, '/')) {
// [模块/控制器/操作]
$path = explode('/', $url);
} elseif (false !== strpos($url, '=')) {
// 参数1=值1&参数2=值2...
parse_str($url, $var);
} else {
$path = [$url];
}

View File

@ -57,7 +57,7 @@ class Template
protected $storage;
/**
* 构函数
* 函数
* @access public
*/
public function __construct(array $config = [])

View File

@ -80,6 +80,9 @@ class Url
if (!empty($match[1])) {
$domain = $match[1];
}
if (!is_null($match[2])) {
$suffix = $match[2];
}
} elseif (!empty($rule) && isset($name)) {
throw new \InvalidArgumentException('route name not exists:' . $name);
} else {
@ -288,18 +291,18 @@ class Url
public static function getRuleUrl($rule, &$vars = [])
{
foreach ($rule as $item) {
list($url, $pattern, $domain) = $item;
list($url, $pattern, $domain, $suffix) = $item;
if (empty($pattern)) {
return [$url, $domain];
return [$url, $domain, $suffix];
}
foreach ($pattern as $key => $val) {
if (isset($vars[$key])) {
$url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key . '', '<' . $key . '>'], $vars[$key], $url);
unset($vars[$key]);
$result = [$url, $domain];
$result = [$url, $domain, $suffix];
} elseif (2 == $val) {
$url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url);
$result = [$url, $domain];
$result = [$url, $domain, $suffix];
} else {
break;
}

View File

@ -102,7 +102,7 @@ class Validate
protected $batch = false;
/**
* 构函数
* 函数
* @access public
* @param array $rules 验证规则
* @param array $message 验证提示信息

View File

@ -25,7 +25,7 @@ class View
protected $replace = [];
/**
* 构函数
* 函数
* @access public
* @param array $engine 模板引擎参数
* @param array $replace 字符串替换参数

View File

@ -28,7 +28,7 @@ class File extends Driver
];
/**
* 构函数
* 函数
* @param array $options
*/
public function __construct($options = [])
@ -225,6 +225,7 @@ class File extends Driver
foreach ($files as $path) {
if (is_dir($path)) {
array_map('unlink', glob($path . '/*.php'));
rmdir($path);
} else {
unlink($path);
}

View File

@ -26,7 +26,7 @@ class Lite extends Driver
];
/**
* 构函数
* 函数
* @access public
*
* @param array $options

View File

@ -25,7 +25,7 @@ class Memcache extends Driver
];
/**
* 构函数
* 函数
* @param array $options 缓存参数
* @access public
* @throws \BadFunctionCallException

View File

@ -27,7 +27,7 @@ class Memcached extends Driver
];
/**
* 构函数
* 函数
* @param array $options 缓存参数
* @access public
*/

View File

@ -34,7 +34,7 @@ class Redis extends Driver
];
/**
* 构函数
* 函数
* @param array $options 缓存参数
* @access public
*/

View File

@ -28,7 +28,7 @@ class Sqlite extends Driver
];
/**
* 构函数
* 函数
* @param array $options 缓存参数
* @throws \BadFunctionCallException
* @access public

View File

@ -25,7 +25,7 @@ class Wincache extends Driver
];
/**
* 构函数
* 函数
* @param array $options 缓存参数
* @throws \BadFunctionCallException
* @access public

View File

@ -25,7 +25,7 @@ class Xcache extends Driver
];
/**
* 构函数
* 函数
* @param array $options 缓存参数
* @access public
* @throws \BadFunctionCallException

View File

@ -32,7 +32,7 @@ abstract class Rest
];
/**
* 构函数 取得模板对象实例
* 函数 取得模板对象实例
* @access public
*/
public function __construct()

View File

@ -18,7 +18,7 @@ abstract class Yar
{
/**
* 构函数
* 函数
* @access public
*/
public function __construct()

View File

@ -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 数据库查询对象实例
@ -379,7 +379,7 @@ abstract class Builder
} 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 查询

View File

@ -125,7 +125,7 @@ abstract class Connection
protected $bind = [];
/**
* 构函数 读取数据库配置信息
* 函数 读取数据库配置信息
* @access public
* @param array $config 数据库配置数组
*/
@ -365,8 +365,8 @@ abstract class Connection
$this->bind = $bind;
}
//释放前次的查询结果
if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) {
// 释放前次的查询结果
if (!empty($this->PDOStatement)) {
$this->free();
}

View File

@ -54,7 +54,7 @@ class Query
private static $event = [];
/**
* 构函数
* 函数
* @access public
* @param Connection $connection 数据库对象实例
* @param string $model 模型名
@ -869,7 +869,7 @@ class Query
public function view($join, $field = true, $on = null, $type = 'INNER')
{
$this->options['view'] = true;
if (is_array($join) && is_null($field)) {
if (is_array($join) && key($join) !== 0) {
foreach ($join as $key => $val) {
$this->view($key, $val[0], isset($val[1]) ? $val[1] : null, isset($val[2]) ? $val[2] : 'INNER');
}
@ -893,7 +893,7 @@ class Query
} else {
$name = $alias . '.' . $key;
}
$fields[] = $name . ' AS ' . $val;
$fields[$name] = $val;
$this->options['map'][$val] = $name;
}
}
@ -1895,7 +1895,7 @@ class Query
$relation = Loader::parseName($relation, 1, false);
$model = $class->$relation();
if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) {
$model->eagerly($this, $relation, $subRelation, $closure, $first);
$model->removeOption()->eagerly($this, $relation, $subRelation, $closure, $first);
$first = false;
} elseif ($closure) {
$with[$key] = $closure;
@ -2065,8 +2065,10 @@ class Query
$sequence = $sequence ?: (isset($options['sequence']) ? $options['sequence'] : null);
$lastInsId = $this->getLastInsID($sequence);
if ($lastInsId) {
$pk = $this->getPk($options);
$data[$pk] = $lastInsId;
$pk = $this->getPk($options);
if (is_string($pk)) {
$data[$pk] = $lastInsId;
}
}
$options['data'] = $data;
$this->trigger('after_insert', $options);
@ -2202,11 +2204,13 @@ class Query
if (isset($key) && Cache::get($key)) {
// 删除缓存
Cache::rm($key);
} elseif (!empty($options['cache']['tag'])) {
Cache::clear($options['cache']['tag']);
}
// 执行操作
$result = '' == $sql ? 0 : $this->execute($sql, $bind);
if ($result) {
if (isset($where[$pk])) {
if (is_string($pk) && isset($where[$pk])) {
$data[$pk] = $where[$pk];
} elseif (is_string($pk) && isset($key) && strpos($key, '|')) {
list($a, $val) = explode('|', $key);
@ -2298,7 +2302,7 @@ class Query
}
}
if (isset($cache)) {
if (isset($cache) && $resultSet) {
// 缓存数据集
$this->cacheData($key, $resultSet, $cache);
}
@ -2375,6 +2379,8 @@ class Query
}
if (isset($data)) {
return 'think:' . $options['table'] . '|' . $data;
} else {
return md5(serialize($options));
}
}
@ -2412,8 +2418,10 @@ class Query
$cache = $options['cache'];
if (true === $cache['key'] && !is_null($data) && !is_array($data)) {
$key = 'think:' . (is_array($options['table']) ? key($options['table']) : $options['table']) . '|' . $data;
} elseif (is_string($cache['key'])) {
$key = $cache['key'];
} elseif (!isset($key)) {
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
$key = md5(serialize($options));
}
$result = Cache::get($key);
}
@ -2451,7 +2459,7 @@ class Query
$result = isset($resultSet[0]) ? $resultSet[0] : null;
}
if (isset($cache)) {
if (isset($cache) && $result) {
// 缓存数据
$this->cacheData($key, $result, $cache);
}
@ -2644,6 +2652,8 @@ class Query
if (isset($key) && Cache::get($key)) {
// 删除缓存
Cache::rm($key);
} elseif (!empty($options['cache']['tag'])) {
Cache::clear($options['cache']['tag']);
}
// 执行操作
$result = $this->execute($sql, $bind);

View File

@ -36,6 +36,9 @@ class Mysql extends Builder
$key = 'json_extract(' . $field . ', \'$.' . $name . '\')';
} elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) {
list($table, $key) = explode('.', $key, 2);
if ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
}

View File

@ -55,6 +55,9 @@ class Pgsql extends Builder
$key = $field . '->>\'' . $name . '\'';
} elseif (strpos($key, '.')) {
list($table, $key) = explode('.', $key, 2);
if ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
}

View File

@ -60,6 +60,9 @@ class Sqlite extends Builder
$key = trim($key);
if (strpos($key, '.')) {
list($table, $key) = explode('.', $key, 2);
if ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
}

View File

@ -73,6 +73,9 @@ class Sqlsrv extends Builder
$key = trim($key);
if (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) {
list($table, $key) = explode('.', $key, 2);
if ('__TABLE__' == $table) {
$table = $this->query->getTable();
}
if (isset($options['alias'][$table])) {
$table = $options['alias'][$table];
}

View File

@ -43,7 +43,7 @@ class Socket
protected $allowForceClientIds = []; //配置强制推送且被授权的client_id
/**
* 构函数
* 函数
* @param array $config 缓存参数
* @access public
*/

View File

@ -22,7 +22,7 @@ class Merge extends Model
protected $mapFields = []; // 需要处理的模型映射字段,避免混淆 array( id => 'user.id' )
/**
* 构函数
* 函数
* @access public
* @param array|object $data 数据
*/

View File

@ -17,7 +17,7 @@ class Pivot extends Model
{
/**
* 构函数
* 函数
* @access public
* @param array|object $data 数据
* @param string $table 中间数据表名

View File

@ -17,7 +17,7 @@ use think\Model;
class BelongsTo extends OneToOne
{
/**
* 构函数
* 函数
* @access public
* @param Model $parent 上级模型对象
* @param string $model 模型名
@ -51,6 +51,45 @@ class BelongsTo extends OneToOne
return $this->query->where($this->localKey, $this->parent->$foreignKey)->relation($subRelation)->find();
}
/**
* 根据关联条件查询当前模型
* @access public
* @param string $operator 比较操作符
* @param integer $count 个数
* @param string $id 关联表的统计字段
* @param string $joinType JOIN类型
* @return Query
*/
public function has($operator = '>=', $count = 1, $id = '*')
{
return $this->parent;
}
/**
* 根据关联条件查询当前模型
* @access public
* @param mixed $where 查询条件(数组或者闭包)
* @return Query
*/
public function hasWhere($where = [])
{
$table = $this->query->getTable();
$model = basename(str_replace('\\', '/', get_class($this->parent)));
$relation = basename(str_replace('\\', '/', $this->model));
if (is_array($where)) {
foreach ($where as $key => $val) {
if (false === strpos($key, '.')) {
$where[$relation . '.' . $key] = $val;
unset($where[$key]);
}
}
}
return $this->parent->db()->alias($model)
->field($model . '.*')
->join($table . ' ' . $relation, $model . '.' . $this->foreignKey . '=' . $relation . '.' . $this->localKey, $this->joinType)
->where($where);
}
/**
* 预载入关联查询(数据集)
* @access public
@ -85,10 +124,10 @@ class BelongsTo extends OneToOne
// 关联数据封装
foreach ($resultSet as $result) {
// 关联模型
if (!isset($data[$result->$localKey])) {
if (!isset($data[$result->$foreignKey])) {
$relationModel = null;
} else {
$relationModel = $data[$result->$localKey];
$relationModel = $data[$result->$foreignKey];
}
if ($relationModel && !empty($this->bindAttr)) {
@ -116,10 +155,10 @@ class BelongsTo extends OneToOne
$foreignKey = $this->foreignKey;
$data = $this->eagerlyWhere($this, [$localKey => $result->$foreignKey], $localKey, $relation, $subRelation, $closure);
// 关联模型
if (!isset($data[$result->$localKey])) {
if (!isset($data[$result->$foreignKey])) {
$relationModel = null;
} else {
$relationModel = $data[$result->$localKey];
$relationModel = $data[$result->$foreignKey];
}
if ($relationModel && !empty($this->bindAttr)) {
// 绑定关联属性

View File

@ -24,7 +24,7 @@ class BelongsToMany extends Relation
protected $middle;
/**
* 构函数
* 函数
* @access public
* @param Model $parent 上级模型对象
* @param string $model 模型名
@ -76,6 +76,31 @@ class BelongsToMany extends Relation
return $result;
}
/**
* 根据关联条件查询当前模型
* @access public
* @param string $operator 比较操作符
* @param integer $count 个数
* @param string $id 关联表的统计字段
* @param string $joinType JOIN类型
* @return Query
*/
public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER')
{
return $this->parent;
}
/**
* 根据关联条件查询当前模型
* @access public
* @param mixed $where 查询条件(数组或者闭包)
* @return Query
*/
public function hasWhere($where = [])
{
throw new Exception('relation not support: hasWhere');
}
/**
* 预载入关联查询(数据集)
* @access public

View File

@ -20,7 +20,7 @@ use think\model\Relation;
class HasMany extends Relation
{
/**
* 构函数
* 函数
* @access public
* @param Model $parent 上级模型对象
* @param string $model 模型名

View File

@ -13,6 +13,7 @@ namespace think\model\relation;
use think\Db;
use think\db\Query;
use think\Exception;
use think\Loader;
use think\Model;
use think\model\Relation;
@ -25,7 +26,7 @@ class HasManyThrough extends Relation
protected $through;
/**
* 构函数
* 函数
* @access public
* @param Model $parent 上级模型对象
* @param string $model 模型名
@ -54,11 +55,36 @@ class HasManyThrough extends Relation
public function getRelation($subRelation = '', $closure = null)
{
if ($closure) {
call_user_func_array($closure, [& $this->query]);
call_user_func_array($closure, [ & $this->query]);
}
return $this->relation($subRelation)->select();
}
/**
* 根据关联条件查询当前模型
* @access public
* @param string $operator 比较操作符
* @param integer $count 个数
* @param string $id 关联表的统计字段
* @param string $joinType JOIN类型
* @return Query
*/
public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER')
{
return $this->parent;
}
/**
* 根据关联条件查询当前模型
* @access public
* @param mixed $where 查询条件(数组或者闭包)
* @return Query
*/
public function hasWhere($where = [])
{
throw new Exception('relation not support: hasWhere');
}
/**
* 预载入关联查询
* @access public

View File

@ -18,7 +18,7 @@ use think\Model;
class HasOne extends OneToOne
{
/**
* 构函数
* 函数
* @access public
* @param Model $parent 上级模型对象
* @param string $model 模型名
@ -47,12 +47,28 @@ class HasOne extends OneToOne
// 执行关联定义方法
$localKey = $this->localKey;
if ($closure) {
call_user_func_array($closure, [& $this->query]);
call_user_func_array($closure, [ & $this->query]);
}
// 判断关联类型执行查询
return $this->query->where($this->foreignKey, $this->parent->$localKey)->relation($subRelation)->find();
}
/**
* 根据关联条件查询当前模型
* @access public
* @return Query
*/
public function has()
{
$table = $this->query->getTable();
$localKey = $this->localKey;
$foreignKey = $this->foreignKey;
return $this->parent->db()->alias('a')
->whereExists(function ($query) use ($table, $localKey, $foreignKey) {
$query->table([$table => 'b'])->field('b.' . $foreignKey)->whereExp('a.' . $localKey, '=b.' . $foreignKey);
});
}
/**
* 根据关联条件查询当前模型
* @access public

View File

@ -13,6 +13,7 @@ namespace think\model\relation;
use think\Db;
use think\db\Query;
use think\Exception;
use think\Loader;
use think\Model;
use think\model\Relation;
@ -26,7 +27,7 @@ class MorphMany extends Relation
protected $type;
/**
* 构函数
* 函数
* @access public
* @param Model $parent 上级模型对象
* @param string $model 模型名
@ -53,11 +54,36 @@ class MorphMany extends Relation
public function getRelation($subRelation = '', $closure = null)
{
if ($closure) {
call_user_func_array($closure, [& $this->query]);
call_user_func_array($closure, [ & $this->query]);
}
return $this->relation($subRelation)->select();
}
/**
* 根据关联条件查询当前模型
* @access public
* @param string $operator 比较操作符
* @param integer $count 个数
* @param string $id 关联表的统计字段
* @param string $joinType JOIN类型
* @return Query
*/
public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER')
{
throw new Exception('relation not support: has');
}
/**
* 根据关联条件查询当前模型
* @access public
* @param mixed $where 查询条件(数组或者闭包)
* @return Query
*/
public function hasWhere($where = [])
{
throw new Exception('relation not support: hasWhere');
}
/**
* 预载入关联查询
* @access public
@ -113,7 +139,7 @@ class MorphMany extends Relation
if (isset($result->$pk)) {
$data = $this->eagerlyMorphToMany([
$this->morphKey => $result->$pk,
$this->morphType => $this->type
$this->morphType => $this->type,
], $relation, $subRelation, $closure);
$result->setAttr(Loader::parseName($relation), $this->resultSetBuild($data[$result->$pk]));
}
@ -132,7 +158,7 @@ class MorphMany extends Relation
$count = 0;
if (isset($result->$pk)) {
if ($closure) {
call_user_func_array($closure, [& $this->query]);
call_user_func_array($closure, [ & $this->query]);
}
$count = $this->query->where([$this->morphKey => $result->$pk, $this->morphType => $this->type])->count();
}
@ -148,15 +174,15 @@ class MorphMany extends Relation
public function getRelationCountQuery($closure)
{
if ($closure) {
call_user_func_array($closure, [& $this->query]);
call_user_func_array($closure, [ & $this->query]);
}
return $this->query->where([
$this->morphKey => [
'exp',
'=' . $this->parent->getTable() . '.' . $this->parent->getPk()
'=' . $this->parent->getTable() . '.' . $this->parent->getPk(),
],
$this->morphType => $this->type
$this->morphType => $this->type,
])->fetchSql()->count();
}
@ -173,7 +199,7 @@ class MorphMany extends Relation
{
// 预载入关联查询 支持嵌套预载入
if ($closure) {
call_user_func_array($closure, [& $this]);
call_user_func_array($closure, [ & $this]);
}
$list = $this->query->where($where)->with($subRelation)->select();
$morphKey = $this->morphKey;

View File

@ -25,7 +25,7 @@ class MorphTo extends Relation
protected $alias;
/**
* 构函数
* 函数
* @access public
* @param Model $parent 上级模型对象
* @param string $morphType 多态字段名
@ -57,6 +57,31 @@ class MorphTo extends Relation
return (new $model)->relation($subRelation)->find($pk);
}
/**
* 根据关联条件查询当前模型
* @access public
* @param string $operator 比较操作符
* @param integer $count 个数
* @param string $id 关联表的统计字段
* @param string $joinType JOIN类型
* @return Query
*/
public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER')
{
return $this->parent;
}
/**
* 根据关联条件查询当前模型
* @access public
* @param mixed $where 查询条件(数组或者闭包)
* @return Query
*/
public function hasWhere($where = [])
{
throw new Exception('relation not support: hasWhere');
}
/**
* 解析模型的完整命名空间
* @access public
@ -89,6 +114,16 @@ class MorphTo extends Relation
return $this;
}
/**
* 移除关联查询参数
* @access public
* @return $this
*/
public function removeOption()
{
return $this;
}
/**
* 预载入关联查询
* @access public

View File

@ -67,6 +67,7 @@ abstract class OneToOne extends Relation
$field = true;
}
$query->field($field, false, $table, $alias);
$field = null;
}
// 预载入封装
@ -82,7 +83,7 @@ abstract class OneToOne extends Relation
if ($closure) {
// 执行闭包查询
call_user_func_array($closure, [& $query]);
call_user_func_array($closure, [ & $query]);
// 使用withField指定获取关联的字段
// $query->where(['id'=>1])->withField('id,name');
if ($query->getOptions('with_field')) {
@ -91,10 +92,8 @@ abstract class OneToOne extends Relation
}
} elseif (isset($this->option['field'])) {
$field = $this->option['field'];
} else {
$field = true;
}
$query->field($field, false, $joinTable, $joinAlias, $relation . '__');
$query->field(isset($field) ? $field : true, false, $joinTable, $joinAlias, $relation . '__');
}
/**
@ -195,7 +194,6 @@ abstract class OneToOne extends Relation
*/
public function getEagerlyType()
{
$this->removeOption();
return $this->eagerlyType;
}
@ -290,7 +288,7 @@ abstract class OneToOne extends Relation
{
// 预载入关联查询 支持嵌套预载入
if ($closure) {
call_user_func_array($closure, [& $model]);
call_user_func_array($closure, [ & $model]);
if ($field = $model->getOptions('with_field')) {
$model->field($field)->removeOption('with_field');
}

View File

@ -68,7 +68,7 @@ class TagLib
protected $comparison = [' nheq ' => ' !== ', ' heq ' => ' === ', ' neq ' => ' != ', ' eq ' => ' == ', ' egt ' => ' >= ', ' gt ' => ' > ', ' elt ' => ' <= ', ' lt ' => ' < '];
/**
* 构函数
* 函数
* @access public
* @param \stdClass $template 模板引擎对象
*/

View File

@ -142,7 +142,7 @@ trait SoftDelete
{
$field = isset($this->deleteTime) ? $this->deleteTime : 'delete_time';
if (!strpos($field, '.')) {
$field = $this->db(false)->getTable() . '.' . $field;
$field = '__TABLE__.' . $field;
}
if (!$read && strpos($field, '.')) {
$array = explode('.', $field);

View File

@ -79,15 +79,17 @@
<html>
<head>
<meta charset="UTF-8">
<title>系统发生错误</title>
<title><?php echo lang('System Error'); ?></title>
<meta name="robots" content="noindex,nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<style>
/* Base */
body {
color: #333;
font: 16px Verdana, "Helvetica Neue", helvetica, Arial, 'Microsoft YaHei', sans-serif;
font: 14px Verdana, "Helvetica Neue", helvetica, Arial, 'Microsoft YaHei', sans-serif;
margin: 0;
padding: 0 20px 20px;
word-break: break-word;
}
h1{
margin: 10px 0 0;
@ -103,6 +105,11 @@
font-size: 18px;
border-bottom: 1px solid #eee;
}
h3.subheading {
color: #4288ce;
margin: 6px 0 0;
font-weight: 400;
}
h3{
margin: 12px;
font-size: 16px;
@ -143,7 +150,27 @@
padding: 0;
margin: 0;
}
/* Layout */
.col-md-3 {
width: 25%;
}
.col-md-9 {
width: 75%;
}
[class^="col-md-"] {
float: left;
}
.clearfix {
clear:both;
}
@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px) {
.col-md-3,
.col-md-9 {
width: 100%;
}
}
/* Exception Info */
.exception {
margin-top: 20px;
@ -378,16 +405,19 @@
<div class="exception-var">
<h2>Environment Variables</h2>
<?php foreach ((array) $tables as $label => $value) { ?>
<table>
<div>
<?php if(empty($value)){ ?>
<caption><?php echo $label; ?><small>empty</small></caption>
<div class="clearfix">
<div class="col-md-3"><strong><?php echo $label; ?></strong></div>
<div class="col-md-9"><small>empty</small></div>
</div>
<?php } else { ?>
<caption><?php echo $label; ?></caption>
<tbody>
<h3 class="subheading"><?php echo $label; ?></h3>
<div>
<?php foreach ((array) $value as $key => $val) { ?>
<tr>
<td><?php echo htmlentities($key); ?></td>
<td>
<div class="clearfix">
<div class="col-md-3"><strong><?php echo htmlentities($key); ?></strong></div>
<div class="col-md-9"><small>
<?php
if(is_array($val) || is_object($val)){
echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
@ -399,12 +429,12 @@
echo 'Resource';
}
?>
</td>
</tr>
</small></div>
</div>
<?php } ?>
</tbody>
</div>
<?php } ?>
</table>
</div>
<?php } ?>
</div>
<?php } ?>

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit26cb3a20d8134d0aa7a7901478c9dcc2::getLoader();
return ComposerAutoloaderInitb4a7bd279920664bf19a780615ee880b::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit26cb3a20d8134d0aa7a7901478c9dcc2
class ComposerAutoloaderInitb4a7bd279920664bf19a780615ee880b
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInit26cb3a20d8134d0aa7a7901478c9dcc2
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit26cb3a20d8134d0aa7a7901478c9dcc2', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitb4a7bd279920664bf19a780615ee880b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit26cb3a20d8134d0aa7a7901478c9dcc2', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitb4a7bd279920664bf19a780615ee880b', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit26cb3a20d8134d0aa7a7901478c9dcc2::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitb4a7bd279920664bf19a780615ee880b::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInit26cb3a20d8134d0aa7a7901478c9dcc2
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit26cb3a20d8134d0aa7a7901478c9dcc2::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitb4a7bd279920664bf19a780615ee880b::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire26cb3a20d8134d0aa7a7901478c9dcc2($fileIdentifier, $file);
composerRequireb4a7bd279920664bf19a780615ee880b($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire26cb3a20d8134d0aa7a7901478c9dcc2($fileIdentifier, $file)
function composerRequireb4a7bd279920664bf19a780615ee880b($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit26cb3a20d8134d0aa7a7901478c9dcc2
class ComposerStaticInitb4a7bd279920664bf19a780615ee880b
{
public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
@ -273,9 +273,9 @@ class ComposerStaticInit26cb3a20d8134d0aa7a7901478c9dcc2
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit26cb3a20d8134d0aa7a7901478c9dcc2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit26cb3a20d8134d0aa7a7901478c9dcc2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit26cb3a20d8134d0aa7a7901478c9dcc2::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitb4a7bd279920664bf19a780615ee880b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb4a7bd279920664bf19a780615ee880b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb4a7bd279920664bf19a780615ee880b::$classMap;
}, null, ClassLoader::class);
}

View File

@ -10,7 +10,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-installer/4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d.zip",
"url": "https://files.phpcomposer.com/files/top-think/think-installer/4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d.zip",
"reference": "4c6e1ebecd1afce3f4ccc47e147d61bbe1bf641d",
"shasum": ""
},
@ -53,7 +53,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/ivanlanin/pclzip/19dd1de9d3f5fc4d7d70175b4c344dee329f45fd.zip",
"url": "https://files.phpcomposer.com/files/ivanlanin/pclzip/19dd1de9d3f5fc4d7d70175b4c344dee329f45fd.zip",
"reference": "19dd1de9d3f5fc4d7d70175b4c344dee329f45fd",
"shasum": ""
},
@ -92,7 +92,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/zoujingli/wechat-php-sdk/12759d48867aab14e6b66be81a5b5afe223a0476.zip",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/12759d48867aab14e6b66be81a5b5afe223a0476.zip",
"reference": "12759d48867aab14e6b66be81a5b5afe223a0476",
"shasum": ""
},
@ -128,7 +128,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/qiniu/php-sdk/b91653485e36b4797d7a302cc86c49695e47a642.zip",
"url": "https://files.phpcomposer.com/files/qiniu/php-sdk/b91653485e36b4797d7a302cc86c49695e47a642.zip",
"reference": "b91653485e36b4797d7a302cc86c49695e47a642",
"shasum": ""
},
@ -172,17 +172,17 @@
},
{
"name": "topthink/framework",
"version": "v5.0.6",
"version_normalized": "5.0.6.0",
"version": "v5.0.7",
"version_normalized": "5.0.7.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "a3a37e6cfad132d5b02ffff8f23a4abc565f7928"
"reference": "bcf64f19f4fadbff6c8503891689ff7e6f2fe9a3"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/framework/a3a37e6cfad132d5b02ffff8f23a4abc565f7928.zip",
"reference": "a3a37e6cfad132d5b02ffff8f23a4abc565f7928",
"url": "https://files.phpcomposer.com/files/top-think/framework/bcf64f19f4fadbff6c8503891689ff7e6f2fe9a3.zip",
"reference": "bcf64f19f4fadbff6c8503891689ff7e6f2fe9a3",
"shasum": ""
},
"require": {
@ -197,7 +197,7 @@
"phpunit/phpunit": "4.8.*",
"sebastian/phpcpd": "2.*"
},
"time": "2017-02-07 09:39:59",
"time": "2017-02-25 02:51:57",
"type": "think-framework",
"installation-source": "dist",
"autoload": {
@ -234,7 +234,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-captcha/0c55455df26a1626a60d0dc35d2d89002b741d44.zip",
"url": "https://files.phpcomposer.com/files/top-think/think-captcha/0c55455df26a1626a60d0dc35d2d89002b741d44.zip",
"reference": "0c55455df26a1626a60d0dc35d2d89002b741d44",
"shasum": ""
},
@ -263,20 +263,20 @@
},
{
"name": "topthink/think-mongo",
"version": "v1.5",
"version_normalized": "1.5.0.0",
"version": "v1.6",
"version_normalized": "1.6.0.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-mongo.git",
"reference": "2dd7ecae965cd3a6e5cc99f3db7c63353dae4cf3"
"reference": "1c6d29f58bd7caa8da088c167b4e65ddac621588"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-mongo/2dd7ecae965cd3a6e5cc99f3db7c63353dae4cf3.zip",
"reference": "2dd7ecae965cd3a6e5cc99f3db7c63353dae4cf3",
"url": "https://files.phpcomposer.com/files/top-think/think-mongo/1c6d29f58bd7caa8da088c167b4e65ddac621588.zip",
"reference": "1c6d29f58bd7caa8da088c167b4e65ddac621588",
"shasum": ""
},
"time": "2017-02-06 06:05:55",
"time": "2017-02-13 07:17:51",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -308,7 +308,7 @@
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-helper/ed64408cdc4cdbd390365ba0906d208b987af520.zip",
"url": "https://files.phpcomposer.com/files/top-think/think-helper/ed64408cdc4cdbd390365ba0906d208b987af520.zip",
"reference": "ed64408cdc4cdbd390365ba0906d208b987af520",
"shasum": ""
},
@ -337,24 +337,24 @@
},
{
"name": "topthink/think-queue",
"version": "v1.1.2",
"version_normalized": "1.1.2.0",
"version": "v1.1.3",
"version_normalized": "1.1.3.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-queue.git",
"reference": "503c5b809585ca60cba9485a233aa8be4b22c990"
"reference": "07480c36381344bef9db9c9bbe3de28005a839d3"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/top-think/think-queue/503c5b809585ca60cba9485a233aa8be4b22c990.zip",
"reference": "503c5b809585ca60cba9485a233aa8be4b22c990",
"url": "https://files.phpcomposer.com/files/top-think/think-queue/07480c36381344bef9db9c9bbe3de28005a839d3.zip",
"reference": "07480c36381344bef9db9c9bbe3de28005a839d3",
"shasum": ""
},
"require": {
"topthink/think-helper": ">=1.0.4",
"topthink/think-installer": ">=1.0.10"
},
"time": "2016-12-01 04:29:39",
"time": "2017-02-28 08:07:37",
"type": "think-extend",
"extra": {
"think-config": {

View File

@ -28,7 +28,7 @@ class Builder
// 最后插入ID
protected $insertId = [];
// 查询表达式
protected $exp = ['<>' => 'ne', 'neq' => 'ne', '=' => 'eq', '>' => 'gt', '>=' => 'gte', '<' => 'lt', '<=' => 'lte', 'in' => 'in', 'not in' => 'nin', 'nin' => 'nin', 'mod' => 'mod', 'exists' => 'exists', 'null' => 'null', 'notnull' => 'not null', 'not null' => 'not null', 'regex' => 'regex', 'type' => 'type', 'all' => 'all', '> time' => '> time', '< time' => '< time', 'between' => 'between', 'not between' => 'not between', 'between time' => 'between time', 'not between time' => 'not between time', 'notbetween time' => 'not between time', 'like' => 'like', 'near' => 'near'];
protected $exp = ['<>' => 'ne', 'neq' => 'ne', '=' => 'eq', '>' => 'gt', '>=' => 'gte', '<' => 'lt', '<=' => 'lte', 'in' => 'in', 'not in' => 'nin', 'nin' => 'nin', 'mod' => 'mod', 'exists' => 'exists', 'null' => 'null', 'notnull' => 'not null', 'not null' => 'not null', 'regex' => 'regex', 'type' => 'type', 'all' => 'all', '> time' => '> time', '< time' => '< time', 'between' => 'between', 'not between' => 'not between', 'between time' => 'between time', 'not between time' => 'not between time', 'notbetween time' => 'not between time', 'like' => 'like', 'near' => 'near', 'size' => 'size'];
/**
* 架构函数
@ -50,8 +50,8 @@ class Builder
*/
protected function parseKey($key)
{
if (strpos($key, '.')) {
list($collection, $key) = explode('.', $key);
if (0 === strpos($key, '__TABLE__.')) {
list($collection, $key) = explode('.', $key, 2);
}
if ('id' == $key && $this->connection->getConfig('pk_convert_id')) {
$key = '_id';
@ -68,7 +68,7 @@ class Builder
*/
protected function parseValue($value, $field = '')
{
if ('_id' == $field && !($value instanceof ObjectID)) {
if ('_id' == $field && 'ObjectID' == $this->connection->getConfig('pk_type') && is_string($value)) {
return new ObjectID($value);
}
return $value;
@ -268,6 +268,9 @@ class Builder
} elseif ('near' == $exp) {
// 经纬度查询
$query[$key] = ['$near' => $this->parseValue($value, $key)];
} elseif ('size' == $exp) {
// 元素长度查询
$query[$key] = ['$size' => intval($value)];
} else {
// 普通查询
$query[$key] = $this->parseValue($value, $key);
@ -426,6 +429,36 @@ class Builder
return $command;
}
/**
* 聚合查询命令
* @access public
* @param array $options 参数
* @param array $extra 指令和字段
* @return Command
*/
public function aggregate($options, $extra)
{
list($fun, $field) = $extra;
$pipeline = [
['$match' => (object) $this->parseWhere($options['where'])],
['$group' => ['_id' => null, 'aggregate' => ['$' . $fun => '$' . $field]]],
];
$cmd = [
'aggregate' => $options['table'],
'allowDiskUse' => true,
'pipeline' => $pipeline,
];
foreach (['explain', 'collation', 'bypassDocumentValidation', 'readConcern'] as $option) {
if (isset($options[$option])) {
$cmd[$option] = $options[$option];
}
}
$command = new Command($cmd);
$this->log('aggregate', $cmd);
return $command;
}
/**
* 生成distinct命令
* @access public

View File

@ -61,51 +61,55 @@ class Connection
// 数据库连接参数配置
protected $config = [
// 数据库类型
'type' => '',
'type' => '',
// 服务器地址
'hostname' => '',
'hostname' => '',
// 数据库名
'database' => '',
'database' => '',
// 用户名
'username' => '',
'username' => '',
// 密码
'password' => '',
'password' => '',
// 端口
'hostport' => '',
'hostport' => '',
// 连接dsn
'dsn' => '',
'dsn' => '',
// 数据库连接参数
'params' => [],
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
'charset' => 'utf8',
// 主键名
'pk' => '_id',
'pk' => '_id',
// 主键类型
'pk_type' => 'ObjectID',
// 数据库表前缀
'prefix' => '',
'prefix' => '',
// 数据库调试模式
'debug' => false,
'debug' => false,
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'deploy' => 0,
'deploy' => 0,
// 数据库读写是否分离 主从式有效
'rw_separate' => false,
'rw_separate' => false,
// 读写分离后 主服务器数量
'master_num' => 1,
'master_num' => 1,
// 指定从服务器序号
'slave_no' => '',
'slave_no' => '',
// 是否严格检查字段是否存在
'fields_strict' => true,
'fields_strict' => true,
// 数据集返回类型
'resultset_type' => 'array',
'resultset_type' => 'array',
// 自动写入时间戳字段
'auto_timestamp' => false,
'auto_timestamp' => false,
// 时间字段取出后的默认时间格式
'datetime_format' => 'Y-m-d H:i:s',
// 是否需要进行SQL性能分析
'sql_explain' => false,
'sql_explain' => false,
// 是否_id转换为id
'pk_convert_id' => false,
'pk_convert_id' => false,
// typeMap
'type_map' => ['root' => 'array', 'document' => 'array'],
'type_map' => ['root' => 'array', 'document' => 'array'],
// Query对象
'query' => '\\think\\mongo\\Query',
'query' => '\\think\\mongo\\Query',
];
/**
@ -292,7 +296,7 @@ class Connection
$this->debug(true);
$dbName = $dbName ?: $this->dbName;
if ($this->config['debug'] && !empty($this->queryStr)) {
$this->queryStr = 'db.' . $dbName . '.' . $this->queryStr;
$this->queryStr = 'db.' . $this->queryStr;
}
$this->cursor = $this->mongo->executeCommand($dbName, $command, $readPreference);
$this->debug(false);
@ -399,6 +403,9 @@ class Connection
});
}
switch (strtolower($type)) {
case 'aggregate':
$this->queryStr = 'runCommand(' . ($data ? json_encode($data) : '') . ');';
break;
case 'find':
$this->queryStr = $type . '(' . ($data ? json_encode($data) : '') . ')';
if (isset($options['sort'])) {

View File

@ -491,6 +491,63 @@ class Query
return $result[0]['n'];
}
/**
* 聚合查询
* @access public
* @param string $aggregate 聚合指令
* @param string $field 字段名
* @return mixed
*/
public function aggregate($aggregate, $field)
{
$result = $this->cmd('aggregate', [$aggregate, $field]);
return isset($result[0]['result'][0]['aggregate']) ? $result[0]['result'][0]['aggregate'] : 0;
}
/**
* MAX查询
* @access public
* @param string $field 字段名
* @return float
*/
public function max($field)
{
return $this->aggregate('max', $field);
}
/**
* MIN查询
* @access public
* @param string $field 字段名
* @return mixed
*/
public function min($field)
{
return $this->aggregate('min', $field);
}
/**
* SUM查询
* @access public
* @param string $field 字段名
* @return float
*/
public function sum($field)
{
return $this->aggregate('sum', $field);
}
/**
* AVG查询
* @access public
* @param string $field 字段名
* @return float
*/
public function avg($field)
{
return $this->aggregate('avg', $field);
}
/**
* 设置记录的某个字段值
* 支持使用数据库字段和方法
@ -595,6 +652,55 @@ class Query
}
}
/**
* 设置数据
* @access public
* @param mixed $field 字段名或者数据
* @param mixed $value 字段值
* @return $this
*/
public function data($field, $value = null)
{
if (is_array($field)) {
$this->options['data'] = isset($this->options['data']) ? array_merge($this->options['data'], $field) : $field;
} else {
$this->options['data'][$field] = $value;
}
return $this;
}
/**
* 字段值增长
* @access public
* @param string|array $field 字段名
* @param integer $step 增长值
* @return $this
*/
public function inc($field, $step = 1)
{
$fields = is_string($field) ? explode(',', $field) : $field;
foreach ($fields as $field) {
$this->data($field, ['$inc', $step]);
}
return $this;
}
/**
* 字段值减少
* @access public
* @param string|array $field 字段名
* @param integer $step 减少值
* @return $this
*/
public function dec($field, $step = 1)
{
$fields = is_string($field) ? explode(',', $field) : $field;
foreach ($fields as $field) {
$this->data($field, ['$inc', -1 * $step]);
}
return $this;
}
/**
* 指定AND查询条件
* @access public
@ -906,6 +1012,17 @@ class Query
return $this;
}
/**
* 指定当前操作的collection
* @access public
* @param string $collection
* @return $this
*/
public function collection($collection)
{
return $this->table($collection);
}
/**
* 查询缓存
* @access public
@ -1082,6 +1199,18 @@ class Query
return $this;
}
/**
* collation
* @access public
* @param array $collation
* @return $this
*/
public function collation($collation)
{
$this->options['collation'] = $collation;
return $this;
}
/**
* 设置返回字段
* @access public

View File

@ -46,4 +46,4 @@ class Queue
{
return call_user_func_array([self::buildConnector(), $name], $arguments);
}
}
}

View File

@ -33,4 +33,4 @@ if (!function_exists('queue')) {
\think\Queue::push($job, $data, $queue);
}
}
}
}

View File

@ -11,4 +11,4 @@
return [
'connector' => 'Sync'
];
];

View File

@ -25,12 +25,12 @@ class CallQueuedHandler
}
}
public function failed(array $data, $e)
public function failed(array $data)
{
$command = unserialize($data['command']);
if (method_exists($command, 'failed')) {
$command->failed($e);
$command->failed();
}
}
}
}

View File

@ -17,9 +17,9 @@ abstract class Connector
{
protected $options = [];
abstract function push($job, $data = '', $queue = null);
abstract public function push($job, $data = '', $queue = null);
abstract function later($delay, $job, $data = '', $queue = null);
abstract public function later($delay, $job, $data = '', $queue = null);
abstract public function pop($queue = null);
@ -66,4 +66,4 @@ abstract class Connector
return $payload;
}
}
}

View File

@ -210,4 +210,4 @@ abstract class Job
{
return $this->queue;
}
}
}

View File

@ -11,7 +11,6 @@
namespace think\queue;
use Closure;
use think\Process;
@ -79,7 +78,6 @@ class Listener
$this->handleWorkerOutput($type, $line);
});
if ($this->memoryExceeded($memory)) {
$this->stop();
}
@ -163,4 +161,4 @@ class Listener
{
$this->maxTries = $tries;
}
}
}

View File

@ -43,4 +43,4 @@ trait Queueable
return $this;
}
}
}

View File

@ -14,4 +14,4 @@ namespace think\queue;
interface ShouldQueue
{
}
}

View File

@ -92,9 +92,13 @@ class Worker
*/
protected function logFailedJob(Job $job)
{
if (Hook::listen('queue.failed', $job, null, true)) {
$job->delete();
$job->failed();
if (!$job->isDeleted()) {
try {
$job->delete();
$job->failed();
} finally {
Hook::listen('queue.failed', $job);
}
}
return ['job' => $job, 'failed' => true];
@ -110,4 +114,4 @@ class Worker
sleep($seconds);
}
}
}

View File

@ -11,7 +11,6 @@
namespace think\queue\command;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
@ -58,4 +57,4 @@ class Listen extends Command
$this->listener->listen($queue, $delay, $memory, $timeout);
}
}
}

View File

@ -11,7 +11,6 @@
namespace think\queue\command;
use think\Cache;
use think\console\Command;
use think\console\Input;
@ -29,4 +28,4 @@ class Restart extends Command
Cache::set('think:queue:restart', time());
$output->writeln("<info>Broadcasting queue restart signal.</info>");
}
}
}

View File

@ -43,4 +43,4 @@ class Subscribe extends Command
$output->write('<info>Queue subscriber added:</info> <comment>' . $input->getArgument('url') . '</comment>');
}
}
}

View File

@ -199,4 +199,4 @@ class Work extends Command
die;
}
}
}

View File

@ -116,7 +116,7 @@ class Database extends Connector
->order('id', 'asc')
->find();
return $job ? (object)$job : null;
return $job ? (object) $job : null;
}
/**
@ -168,4 +168,4 @@ class Database extends Connector
{
return $queue ?: $this->options['default'];
}
}
}

View File

@ -54,4 +54,4 @@ class Sync extends Connector
return new SyncJob($payload);
}
}
}

View File

@ -170,7 +170,7 @@ class Topthink extends Connector
}
}
$this->reportHttpError($this->last_status, "Service unavailable");
return null;
return;
}
protected static function jsonDecode($response)
@ -210,7 +210,6 @@ class Topthink extends Connector
];
}
public function __destruct()
{
if ($this->curl != null) {
@ -223,4 +222,4 @@ class Topthink extends Connector
{
throw new \RuntimeException('pop queues not support for this type');
}
}
}

View File

@ -74,7 +74,7 @@ class Database extends Job
*/
public function attempts()
{
return (int)$this->job->attempts;
return (int) $this->job->attempts;
}
/**
@ -85,4 +85,4 @@ class Database extends Job
{
return $this->job->payload;
}
}
}

View File

@ -11,14 +11,12 @@
namespace think\queue\job;
use think\queue\Job;
use think\queue\connector\Redis as RedisQueue;
class Redis extends Job
{
/**
* The redis queue instance.
* @var RedisQueue
@ -65,7 +63,6 @@ class Redis extends Job
return $this->job;
}
/**
* 删除任务
*
@ -92,4 +89,4 @@ class Redis extends Job
$this->redis->release($this->queue, $this->job, $delay, $this->attempts() + 1);
}
}
}

View File

@ -11,7 +11,6 @@
namespace think\queue\job;
use think\queue\Job;
class Sync extends Job
@ -54,4 +53,4 @@ class Sync extends Job
{
return $this->payload;
}
}
}

View File

@ -11,7 +11,6 @@
namespace think\queue\job;
use think\queue\Job;
use think\queue\connector\Topthink as TopthinkQueue;
@ -55,7 +54,7 @@ class Topthink extends Job
*/
public function attempts()
{
return (int)$this->job->attempts;
return (int) $this->job->attempts;
}
public function delete()
@ -83,4 +82,4 @@ class Topthink extends Job
return $this->job->payload;
}
}
}