From 2f285c73c18505dc391ea60847aec2226953e59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 14 Sep 2020 10:40:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/ActiveQuery.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Database/ActiveQuery.php b/Database/ActiveQuery.php index 9b1c9260..6f3ce537 100644 --- a/Database/ActiveQuery.php +++ b/Database/ActiveQuery.php @@ -188,20 +188,12 @@ class ActiveQuery extends Component */ public function plunk(int $size, callable $callback, $param = null, $offset = 0, $total = -1) { - if (!is_callable($callback, true)) { - return; - } - $data = $this->limit($offset, $size)->get(); - if ($param !== null) { - call_user_func($callback, $data, $param); - } else { - call_user_func($callback, $data); - } - if ($data->size() < $size) { - return; - } - unset($data); - $this->plunk($size, $callback, $param, $offset + $size, $total); + $pagination = new Pagination($this); + $pagination->setOffset($offset); + $pagination->setLimit($size); + $pagination->setMax($total); + $pagination->setCallback($callback); + $pagination->search($param); } /**