diff --git a/Database/ActiveQuery.php b/Database/ActiveQuery.php index f930a4db..9fdb4dbe 100644 --- a/Database/ActiveQuery.php +++ b/Database/ActiveQuery.php @@ -172,20 +172,18 @@ class ActiveQuery extends Component /** * @param int $size - * @param callable $callback - * @param mixed $param * @param int $offset - * @param int $total + * @param callable $callback + * @return Pagination * @throws Exception */ - public function plunk(int $size, callable $callback, $param = null, $offset = 0, $total = -1) + public function plunk(int $size, int $offset, callable $callback) { $pagination = new Pagination($this); $pagination->setOffset($offset); $pagination->setLimit($size); - $pagination->setMax($total); $pagination->setCallback($callback); - $pagination->search($param); + return $pagination; } /** diff --git a/Database/Pagination.php b/Database/Pagination.php index b1183e57..4e886c37 100644 --- a/Database/Pagination.php +++ b/Database/Pagination.php @@ -99,12 +99,12 @@ class Pagination extends Component /** * @param array $param */ - public function search($param = []) + public function plunk($param = []) { if ($this->_length >= $this->_max) { return; } - [$length, $data] = $this->load(); + [$length, $data] = $this->get(); if ($param !== null) { call_user_func($this->_callback, $data, $param); } else { @@ -114,14 +114,14 @@ class Pagination extends Component if ($length < $this->_limit) { return; } - $this->search($param); + $this->plunk($param); } /** * @return array|Collection */ - private function load() + private function get() { if ($this->_length + $this->_limit > $this->_max) { $this->_limit = $this->_length + $this->_limit - $this->_max;