eee
This commit is contained in:
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace Database\Affair;
|
namespace Database\Affair;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
class Commit
|
class Commit
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use Kiri\Abstracts\Component;
|
|||||||
use Kiri\Di\Container;
|
use Kiri\Di\Container;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use PDO;
|
use PDO;
|
||||||
use PDOStatement;
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Database\Condition;
|
namespace Database\Condition;
|
||||||
|
|
||||||
use Database\ActiveQuery;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Database\Condition;
|
namespace Database\Condition;
|
||||||
|
|
||||||
use Kiri\Core\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LLikeCondition
|
* Class LLikeCondition
|
||||||
* @package Database\Condition
|
* @package Database\Condition
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Database\Condition;
|
namespace Database\Condition;
|
||||||
|
|
||||||
use Kiri\Core\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LikeCondition
|
* Class LikeCondition
|
||||||
* @package Database\Condition
|
* @package Database\Condition
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Database\Condition;
|
namespace Database\Condition;
|
||||||
|
|
||||||
use Kiri\Core\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class NotLikeCondition
|
* Class NotLikeCondition
|
||||||
* @package Database\Condition
|
* @package Database\Condition
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Database\Condition;
|
namespace Database\Condition;
|
||||||
|
|
||||||
use Kiri\Core\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RLikeCondition
|
* Class RLikeCondition
|
||||||
* @package Database\Condition
|
* @package Database\Condition
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ use Database\Mysql\Schema;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Kiri;
|
use Kiri;
|
||||||
use Kiri\Server\Events\OnWorkerExit;
|
use Kiri\Server\Events\OnWorkerExit;
|
||||||
use Kiri\Waite;
|
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Di\Context;
|
use Kiri\Di\Context;
|
||||||
use Kiri\Pool\Pool;
|
use Kiri\Pool\Pool;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Model extends Base\Model
|
|||||||
/** @var static $select */
|
/** @var static $select */
|
||||||
$select = static::query()->where($condition)->first();
|
$select = static::query()->where($condition)->first();
|
||||||
if ($select === null) {
|
if ($select === null) {
|
||||||
$select = static::populate(array_merge($condition, $attributes))->create();
|
$select = static::populate(array_merge($condition, $attributes))->save();
|
||||||
}
|
}
|
||||||
return $select;
|
return $select;
|
||||||
}, $condition, $attributes);
|
}, $condition, $attributes);
|
||||||
@@ -129,7 +129,8 @@ class Model extends Base\Model
|
|||||||
if (empty($select)) {
|
if (empty($select)) {
|
||||||
$select = static::populate($condition);
|
$select = static::populate($condition);
|
||||||
}
|
}
|
||||||
return $select->save($attributes);
|
$select->attributes = $attributes;
|
||||||
|
return $select->save();
|
||||||
}, $condition, $attributes);
|
}, $condition, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-9
@@ -54,8 +54,8 @@ class Pagination extends Component
|
|||||||
{
|
{
|
||||||
unset($this->activeQuery, $this->_callback, $this->_group);
|
unset($this->activeQuery, $this->_callback, $this->_group);
|
||||||
$this->_offset = 0;
|
$this->_offset = 0;
|
||||||
$this->_limit = 100;
|
$this->_limit = 100;
|
||||||
$this->_max = 0;
|
$this->_max = 0;
|
||||||
$this->_length = 0;;
|
$this->_length = 0;;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,14 +196,9 @@ class Pagination extends Component
|
|||||||
if ($this->_max > 0 && $this->_length + $this->_limit > $this->_max) {
|
if ($this->_max > 0 && $this->_length + $this->_limit > $this->_max) {
|
||||||
$this->_limit = $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;
|
$this->_offset += $this->_limit;
|
||||||
|
$size = $data->size();
|
||||||
if (is_array($data)) {
|
|
||||||
$size = count($data);
|
|
||||||
} else {
|
|
||||||
$size = $data->size();
|
|
||||||
}
|
|
||||||
$this->_length += $size;
|
$this->_length += $size;
|
||||||
return [$size, $data];
|
return [$size, $data];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -648,9 +648,6 @@ trait QueryTrait
|
|||||||
*/
|
*/
|
||||||
public function pushParam(mixed $value): static
|
public function pushParam(mixed $value): static
|
||||||
{
|
{
|
||||||
// if (is_string($value)) {
|
|
||||||
// $value = addslashes($value);
|
|
||||||
// }
|
|
||||||
$this->attributes[] = $value;
|
$this->attributes[] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ namespace Database\Traits;
|
|||||||
interface Relation
|
interface Relation
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function get(): mixed;
|
public function get(): mixed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user