This commit is contained in:
2023-10-24 17:22:29 +08:00
parent b0e627c4fb
commit dcf4e0a614
12 changed files with 11 additions and 27 deletions
-2
View File
@@ -2,8 +2,6 @@
namespace Database\Affair;
use Exception;
class Commit
{
-1
View File
@@ -15,7 +15,6 @@ use Kiri\Abstracts\Component;
use Kiri\Di\Container;
use Kiri\Exception\ConfigException;
use PDO;
use PDOStatement;
use Throwable;
/**
-1
View File
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace Database\Condition;
use Database\ActiveQuery;
use Exception;
use JetBrains\PhpStorm\Pure;
-2
View File
@@ -3,8 +3,6 @@ declare(strict_types=1);
namespace Database\Condition;
use Kiri\Core\Str;
/**
* Class LLikeCondition
* @package Database\Condition
-2
View File
@@ -3,8 +3,6 @@ declare(strict_types=1);
namespace Database\Condition;
use Kiri\Core\Str;
/**
* Class LikeCondition
* @package Database\Condition
-2
View File
@@ -3,8 +3,6 @@ declare(strict_types=1);
namespace Database\Condition;
use Kiri\Core\Str;
/**
* Class NotLikeCondition
* @package Database\Condition
-2
View File
@@ -3,8 +3,6 @@ declare(strict_types=1);
namespace Database\Condition;
use Kiri\Core\Str;
/**
* Class RLikeCondition
* @package Database\Condition
-1
View File
@@ -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;
+3 -2
View File
@@ -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);
}
+4 -9
View File
@@ -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];
}
-3
View File
@@ -648,9 +648,6 @@ trait QueryTrait
*/
public function pushParam(mixed $value): static
{
// if (is_string($value)) {
// $value = addslashes($value);
// }
$this->attributes[] = $value;
return $this;
}
+4
View File
@@ -6,6 +6,10 @@ namespace Database\Traits;
interface Relation
{
/**
* @return mixed
*/
public function get(): mixed;
}