This commit is contained in:
xl
2023-11-14 15:01:30 +08:00
parent a1238613f9
commit 53dbf7a9b2
12 changed files with 174 additions and 248 deletions
+8 -20
View File
@@ -51,27 +51,17 @@ class ActiveQuery extends Component implements ISqlBuilder
public function __construct($model)
{
$this->modelClass = $model;
$this->builder = SqlBuilder::builder($this);
$this->builder = SqlBuilder::builder($this);
parent::__construct();
}
/**
* 清除不完整数据
*/
public function clear(): void
{
$this->db = NULL;
$this->useCache = FALSE;
}
/**
* @param $key
* @param $value
* @param string $key
* @param mixed $value
* @return $this
*/
public function addParam($key, $value): static
public function addParam(string $key, mixed $value): static
{
$this->attributes[$key] = $value;
return $this;
@@ -87,13 +77,11 @@ class ActiveQuery extends Component implements ISqlBuilder
#[ArrayShape([])]
public function pagination(int $size = 20, int $page = 1): array
{
$page = max(1, $page);
$size = max(1, $size);
$page = max(1, $page);
$size = max(1, $size);
$offset = ($page - 1) * $size;
$count = $this->count();
$lists = $this->offset($offset)->limit($size)->get()->toArray();
$count = $this->count();
$lists = $this->offset($offset)->limit($size)->get()->toArray();
return [
'code' => 0,
'message' => 'ok',