From 1f0892f93c10cc143989267635f5c64d761d00ec Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 19 Apr 2016 13:25:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bchunk=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8=E8=B0=83=E7=94=A8chunk=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E4=BD=BF=E7=94=A8=E8=BF=9E=E8=B4=AF=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 6c40b6ec..dd33037c 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1180,14 +1180,13 @@ class Query * @param integer $count 每次处理的数据数量 * @param callable $callback 处理回调方法 * @param string $column 分批处理的字段名 - * @param array|Closure $where 查询条件 * @return array */ - public function chunk($count, $callback, $column = null, $where = []) + public function chunk($count, $callback, $column = null) { $column = $column ?: $this->connection->getTableInfo('', 'pk'); - $model = isset($this->options['model']) ? $this->options['model'] : ''; - $resultSet = $this->limit($count)->where($where)->order($column, 'asc')->select(); + $options = $this->getOptions(); + $resultSet = $this->limit($count)->order($column, 'asc')->select(); while (!empty($resultSet)) { if (false === call_user_func($callback, $resultSet)) { @@ -1195,9 +1194,8 @@ class Query } $end = end($resultSet); $lastId = is_array($end) ? $end[$column] : $end->$column; - $resultSet = $this->model($model) + $resultSet = $this->options($options) ->limit($count) - ->where($where) ->where($column, '>', $lastId) ->order($column, 'asc') ->select();