This commit is contained in:
2023-08-14 18:56:45 +08:00
parent 0a567634d6
commit 4a51a8a336
5 changed files with 22 additions and 3 deletions
+3 -1
View File
@@ -339,7 +339,9 @@ class ActiveQuery extends Component implements ISqlBuilder
{
$sql = $this->builder->delete();
if ($getSql === FALSE) {
return (bool)$this->execute($sql, $this->attributes)->delete();
$result = (bool)$this->execute($sql, $this->attributes)->delete();
$this->modelClass->optimize();
return $result;
}
return $sql;
}
+10
View File
@@ -265,6 +265,16 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
}
/**
* @return mixed
* @throws Exception
*/
public function optimize(): mixed
{
return static::query()->execute('OPTIMIZE TABLE ' . $this->getTable())->exec();
}
/**
* @return static
*/
+2 -2
View File
@@ -108,10 +108,10 @@ class Command extends Component
}
/**
* @return bool|array|null
* @return mixed
* @throws Exception
*/
public function fetchColumn(): null|bool|array
public function fetchColumn(): mixed
{
try {
return $this->prepare()->fetchColumn(PDO::FETCH_ASSOC);
+1
View File
@@ -197,6 +197,7 @@ class Model extends Base\Model
} else {
$result = static::deleteByCondition($this->_attributes);
}
$this->optimize();
return $this->afterDelete($result);
}
return false;
+6
View File
@@ -25,6 +25,12 @@ interface ModelInterface
public static function findOne(array|string|int $param, $db = NULL): ?static;
/**
* @return mixed
*/
public function optimize(): mixed;
/**
* @param int $param
* @param null $db