This commit is contained in:
2024-12-13 14:04:58 +08:00
parent f084c171ff
commit b3e3e95081
+19 -6
View File
@@ -23,14 +23,15 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
public bool $asArray = FALSE; public bool $asArray = FALSE;
protected mixed $_mock = null; protected mixed $_mock = NULL;
/** /**
* @param bool $asArray * @param bool $asArray
*
* @return static * @return static
*/ */
public function asArray(bool $asArray = true): static public function asArray(bool $asArray = TRUE): static
{ {
$this->asArray = $asArray; $this->asArray = $asArray;
return $this; return $this;
@@ -38,6 +39,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param array $methods * @param array $methods
*
* @return $this * @return $this
*/ */
public function with(array $methods): static public function with(array $methods): static
@@ -57,7 +59,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
if (is_array($data)) { if (is_array($data)) {
return $this->populate($data); return $this->populate($data);
} }
return null; return NULL;
} }
/** /**
@@ -69,13 +71,14 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
if (is_array($data)) { if (is_array($data)) {
return new Collection($this, $this->modelClass, $data); return new Collection($this, $this->modelClass, $data);
} }
return false; return FALSE;
} }
/** /**
* @param string $column * @param string $column
* @param int|float $amount * @param int|float $amount
*
* @return bool * @return bool
*/ */
public function increment(string $column, int|float $amount = 1): bool public function increment(string $column, int|float $amount = 1): bool
@@ -86,6 +89,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param array $attributes * @param array $attributes
*
* @return bool * @return bool
*/ */
public function increments(array $attributes): bool public function increments(array $attributes): bool
@@ -97,6 +101,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param string $column * @param string $column
* @param int|float $amount * @param int|float $amount
*
* @return bool * @return bool
*/ */
public function decrement(string $column, int|float $amount = 1): bool public function decrement(string $column, int|float $amount = 1): bool
@@ -107,6 +112,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param array $attributes * @param array $attributes
*
* @return bool * @return bool
*/ */
public function decrements(array $attributes): bool public function decrements(array $attributes): bool
@@ -127,6 +133,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param int $size * @param int $size
* @param Closure $closure * @param Closure $closure
*
* @return void * @return void
*/ */
public function chunk(int $size, Closure $closure): void public function chunk(int $size, Closure $closure): void
@@ -151,7 +158,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
* *
* @return array|null * @return array|null
*/ */
public function column(string $field, ?string $setKey = null): ?array public function column(string $field, ?string $setKey = NULL): ?array
{ {
return $this->get()->column($field, $setKey); return $this->get()->column($field, $setKey);
} }
@@ -159,6 +166,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param mixed $value * @param mixed $value
*
* @return $this * @return $this
*/ */
public function withMock(mixed $value): static public function withMock(mixed $value): static
@@ -179,6 +187,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param array $data * @param array $data
*
* @return ModelInterface|array * @return ModelInterface|array
* @throws * @throws
*/ */
@@ -211,13 +220,14 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param array $data * @param array $data
*
* @return bool * @return bool
* @throws * @throws
*/ */
public function update(array $data): bool public function update(array $data): bool
{ {
if (count($data) < 1) { if (count($data) < 1) {
return true; return TRUE;
} }
$generate = $this->builder->update($data); $generate = $this->builder->update($data);
if (!is_bool($generate)) { if (!is_bool($generate)) {
@@ -229,6 +239,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param array $data * @param array $data
*
* @return bool * @return bool
*/ */
public function insert(array $data): bool public function insert(array $data): bool
@@ -238,6 +249,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
return (bool)$this->buildCommand($sql)->exec(); return (bool)$this->buildCommand($sql)->exec();
} }
/** /**
* @param string $filed * @param string $filed
* *
@@ -262,6 +274,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
/** /**
* @param string $sql * @param string $sql
* @param array $params * @param array $params
*
* @return int|bool * @return int|bool
*/ */
public function execute(string $sql, array $params = []): int|bool public function execute(string $sql, array $params = []): int|bool