diff --git a/Affair/Commit.php b/Affair/Commit.php index 6661847..4cbee9a 100644 --- a/Affair/Commit.php +++ b/Affair/Commit.php @@ -2,8 +2,6 @@ namespace Database\Affair; -use Exception; - class Commit { diff --git a/Command.php b/Command.php index 6ed9197..ad5da8c 100644 --- a/Command.php +++ b/Command.php @@ -15,7 +15,6 @@ use Kiri\Abstracts\Component; use Kiri\Di\Container; use Kiri\Exception\ConfigException; use PDO; -use PDOStatement; use Throwable; /** diff --git a/Condition/InCondition.php b/Condition/InCondition.php index be9c4f0..9e9b686 100644 --- a/Condition/InCondition.php +++ b/Condition/InCondition.php @@ -3,7 +3,6 @@ declare(strict_types=1); namespace Database\Condition; -use Database\ActiveQuery; use Exception; use JetBrains\PhpStorm\Pure; diff --git a/Condition/LLikeCondition.php b/Condition/LLikeCondition.php index 7712ec3..e7e3c9e 100644 --- a/Condition/LLikeCondition.php +++ b/Condition/LLikeCondition.php @@ -3,8 +3,6 @@ declare(strict_types=1); namespace Database\Condition; -use Kiri\Core\Str; - /** * Class LLikeCondition * @package Database\Condition diff --git a/Condition/LikeCondition.php b/Condition/LikeCondition.php index 1412e94..0f8ae84 100644 --- a/Condition/LikeCondition.php +++ b/Condition/LikeCondition.php @@ -3,8 +3,6 @@ declare(strict_types=1); namespace Database\Condition; -use Kiri\Core\Str; - /** * Class LikeCondition * @package Database\Condition diff --git a/Condition/NotLikeCondition.php b/Condition/NotLikeCondition.php index 6798aac..d756c32 100644 --- a/Condition/NotLikeCondition.php +++ b/Condition/NotLikeCondition.php @@ -3,8 +3,6 @@ declare(strict_types=1); namespace Database\Condition; -use Kiri\Core\Str; - /** * Class NotLikeCondition * @package Database\Condition diff --git a/Condition/RLikeCondition.php b/Condition/RLikeCondition.php index 1f35123..6fadedc 100644 --- a/Condition/RLikeCondition.php +++ b/Condition/RLikeCondition.php @@ -3,8 +3,6 @@ declare(strict_types=1); namespace Database\Condition; -use Kiri\Core\Str; - /** * Class RLikeCondition * @package Database\Condition diff --git a/Connection.php b/Connection.php index c9f192c..b06e0e4 100644 --- a/Connection.php +++ b/Connection.php @@ -18,7 +18,6 @@ use Database\Mysql\Schema; use Exception; use Kiri; use Kiri\Server\Events\OnWorkerExit; -use Kiri\Waite; use Kiri\Abstracts\Component; use Kiri\Di\Context; use Kiri\Pool\Pool; diff --git a/Model.php b/Model.php index 769c4ed..13191c2 100644 --- a/Model.php +++ b/Model.php @@ -107,7 +107,7 @@ class Model extends Base\Model /** @var static $select */ $select = static::query()->where($condition)->first(); if ($select === null) { - $select = static::populate(array_merge($condition, $attributes))->create(); + $select = static::populate(array_merge($condition, $attributes))->save(); } return $select; }, $condition, $attributes); @@ -129,7 +129,8 @@ class Model extends Base\Model if (empty($select)) { $select = static::populate($condition); } - return $select->save($attributes); + $select->attributes = $attributes; + return $select->save(); }, $condition, $attributes); } diff --git a/Pagination.php b/Pagination.php index 1df720a..49db711 100644 --- a/Pagination.php +++ b/Pagination.php @@ -54,8 +54,8 @@ class Pagination extends Component { unset($this->activeQuery, $this->_callback, $this->_group); $this->_offset = 0; - $this->_limit = 100; - $this->_max = 0; + $this->_limit = 100; + $this->_max = 0; $this->_length = 0;; } @@ -196,14 +196,9 @@ class Pagination extends Component if ($this->_max > 0 && $this->_length + $this->_limit > $this->_max) { $this->_limit = $this->_length + $this->_limit - $this->_max; } - $data = $this->activeQuery->offset($this->_offset)->limit($this->_limit)->get(); + $data = $this->activeQuery->offset($this->_offset)->limit($this->_limit)->get(); $this->_offset += $this->_limit; - - if (is_array($data)) { - $size = count($data); - } else { - $size = $data->size(); - } + $size = $data->size(); $this->_length += $size; return [$size, $data]; } diff --git a/Traits/QueryTrait.php b/Traits/QueryTrait.php index 729c310..cddb05c 100644 --- a/Traits/QueryTrait.php +++ b/Traits/QueryTrait.php @@ -648,9 +648,6 @@ trait QueryTrait */ public function pushParam(mixed $value): static { -// if (is_string($value)) { -// $value = addslashes($value); -// } $this->attributes[] = $value; return $this; } diff --git a/Traits/Relation.php b/Traits/Relation.php index adc5806..0ec2af8 100644 --- a/Traits/Relation.php +++ b/Traits/Relation.php @@ -6,6 +6,10 @@ namespace Database\Traits; interface Relation { + + /** + * @return mixed + */ public function get(): mixed; }