chunk方法添加异常处理

This commit is contained in:
thinkphp
2017-08-31 16:15:24 +08:00
parent aa0583fee4
commit 18aa14924e
2 changed files with 4 additions and 0 deletions

View File

@@ -65,4 +65,5 @@ return [
'bind attr has exists' => '模型的属性已经存在', 'bind attr has exists' => '模型的属性已经存在',
'relation data not exists' => '关联数据不存在', 'relation data not exists' => '关联数据不存在',
'relation not support' => '关联不支持', 'relation not support' => '关联不支持',
'chunk not support order' => 'Chunk不支持调用order方法',
]; ];

View File

@@ -16,6 +16,7 @@ use think\Cache;
use think\Collection; use think\Collection;
use think\Config; use think\Config;
use think\Db; use think\Db;
use think\App;
use think\db\exception\BindParamException; use think\db\exception\BindParamException;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;
@@ -2568,6 +2569,7 @@ class Query
* @param string $column 分批处理的字段名 * @param string $column 分批处理的字段名
* @param string $order 排序规则 * @param string $order 排序规则
* @return boolean * @return boolean
* @throws DbException
*/ */
public function chunk($count, $callback, $column = null, $order = 'asc') public function chunk($count, $callback, $column = null, $order = 'asc')
{ {
@@ -2582,6 +2584,7 @@ class Query
$column = $column[0]; $column = $column[0];
} }
if (isset($options['order'])) { if (isset($options['order'])) {
App::$debug && throw new DbException('chunk not support call order');
unset($options['order']); unset($options['order']);
} }
$bind = $this->bind; $bind = $this->bind;