qqq
This commit is contained in:
+3
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
@@ -197,6 +197,7 @@ class Model extends Base\Model
|
||||
} else {
|
||||
$result = static::deleteByCondition($this->_attributes);
|
||||
}
|
||||
$this->optimize();
|
||||
return $this->afterDelete($result);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user