修正Query类的chunk方法

This commit is contained in:
thinkphp
2016-04-25 12:15:12 +08:00
parent 612a9cbae9
commit 964248a10e

View File

@@ -1256,6 +1256,9 @@ class Query
{ {
$column = $column ?: $this->connection->getTableInfo('', 'pk'); $column = $column ?: $this->connection->getTableInfo('', 'pk');
$options = $this->getOptions(); $options = $this->getOptions();
if (empty($options['table'])) {
$table = $this->connection->getTable();
}
$resultSet = $this->limit($count)->order($column, 'asc')->select(); $resultSet = $this->limit($count)->order($column, 'asc')->select();
while (!empty($resultSet)) { while (!empty($resultSet)) {
@@ -1264,11 +1267,14 @@ class Query
} }
$end = end($resultSet); $end = end($resultSet);
$lastId = is_array($end) ? $end[$column] : $end->$column; $lastId = is_array($end) ? $end[$column] : $end->$column;
$resultSet = $this->options($options) $this->options($options)
->limit($count) ->limit($count)
->where($column, '>', $lastId) ->where($column, '>', $lastId)
->order($column, 'asc') ->order($column, 'asc');
->select(); if (isset($table)) {
$this->table($table);
}
$resultSet = $this->select();
} }
return true; return true;
} }