From 384ce564f95bf31ad5faec44c2053af3b2d0f1f7 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 22 Nov 2016 11:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E5=AF=B9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=AF=B9=E8=B1=A1=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=AD=97=E6=AE=B5=E6=8E=92=E5=BA=8F=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 6020b527..a46bbed4 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -2139,19 +2139,30 @@ class Query $column = $column ?: $this->getPk($table); $bind = $this->bind; $resultSet = $this->limit($count)->order($column, 'asc')->select(); + if (strpos($column, '.')) { + list($alias, $key) = explode('.', $column); + } else { + $key = $column; + } + if ($resultSet instanceof Collection) { + $resultSet = $resultSet->all(); + } while (!empty($resultSet)) { if (false === call_user_func($callback, $resultSet)) { return false; } $end = end($resultSet); - $lastId = is_array($end) ? $end[$column] : $end->$column; + $lastId = is_array($end) ? $end[$key] : $end->$key; $resultSet = $this->options($options) ->limit($count) ->bind($bind) ->where($column, '>', $lastId) ->order($column, 'asc') ->select(); + if ($resultSet instanceof Collection) { + $resultSet = $resultSet->all(); + } } return true; }