Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-07 14:38:36 +08:00
parent cf2f26ec21
commit 614b601afa
3 changed files with 1058 additions and 1065 deletions
+1039 -1040
View File
File diff suppressed because it is too large Load Diff
+5 -13
View File
@@ -39,9 +39,6 @@ class Command extends Component
/** @var string */
public string $dbname = '';
/** @var PDOStatement|null */
private ?PDOStatement $prepare = null;
/**
* @return array|bool|int|string|PDOStatement|null
@@ -53,12 +50,10 @@ class Command extends Component
}
/**
* @param bool $isInsert
* @param mixed $hasAutoIncrement
* @return int|bool|array|string|null
* @throws Exception
*/
public function save(bool $isInsert = TRUE, mixed $hasAutoIncrement = null): int|bool|array|string|null
public function save(): int|bool|array|string|null
{
return $this->execute(static::EXECUTE);
}
@@ -110,11 +105,11 @@ class Command extends Component
}
/**
* @param $type
* @param string $type
* @return int|bool|array|string|null
* @throws Exception
*/
private function execute($type): int|bool|array|string|null
private function execute(string $type): int|bool|array|string|null
{
try {
$time = microtime(true);
@@ -136,11 +131,11 @@ class Command extends Component
/**
* @param $type
* @param string $type
* @return array|int|bool|null
* @throws Exception
*/
private function search($type): array|int|bool|null
private function search(string $type): array|int|bool|null
{
$pdo = $this->db->getConnect($this->sql);
if ($type === static::FETCH_COLUMN) {
@@ -180,9 +175,6 @@ class Command extends Component
*/
public function bindValues(array $data = []): static
{
if (!is_array($this->params)) {
$this->params = [];
}
if (!empty($data)) {
$this->params = array_merge($this->params, $data);
}
+14 -12
View File
@@ -17,6 +17,7 @@ use Kiri\Exception\NotFindClassException;
use Kiri\Kiri;
use Kiri\ToArray;
use ReflectionException;
use Swoole\Coroutine;
defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a new model, but the data cannot be empty.');
@@ -213,16 +214,18 @@ class Model extends Base\Model
*/
public function delete(): bool
{
$conditions = $this->_oldAttributes;
if (empty($conditions)) {
return $this->addError("Delete condition do not empty.", 'mysql');
}
$primary = $this->getPrimary();
if (!empty($primary)) {
$conditions = [$primary => $this->getAttribute($primary)];
if (empty($primary) || !$this->hasPrimaryValue()) {
return $this->addError("Only primary key operations are supported.", 'mysql');
}
return static::deleteByCondition($conditions);
if (!$this->beforeDelete()) {
$result = static::deleteByCondition([$primary => $this->getPrimaryValue()]);
Coroutine::create(function () use ($result) {
$this->afterDelete($result);
});
return $result;
}
return false;
}
@@ -401,12 +404,11 @@ class Model extends Base\Model
}
/**
* @return bool
* @throws Exception
* @param bool $result
* @return void
*/
public function afterDelete(): bool
public function afterDelete(bool $result): void
{
return TRUE;
}
/**