This commit is contained in:
2020-09-14 10:40:49 +08:00
parent be3db38aae
commit 2f285c73c1
+6 -14
View File
@@ -188,20 +188,12 @@ class ActiveQuery extends Component
*/ */
public function plunk(int $size, callable $callback, $param = null, $offset = 0, $total = -1) public function plunk(int $size, callable $callback, $param = null, $offset = 0, $total = -1)
{ {
if (!is_callable($callback, true)) { $pagination = new Pagination($this);
return; $pagination->setOffset($offset);
} $pagination->setLimit($size);
$data = $this->limit($offset, $size)->get(); $pagination->setMax($total);
if ($param !== null) { $pagination->setCallback($callback);
call_user_func($callback, $data, $param); $pagination->search($param);
} else {
call_user_func($callback, $data);
}
if ($data->size() < $size) {
return;
}
unset($data);
$this->plunk($size, $callback, $param, $offset + $size, $total);
} }
/** /**