qqq
This commit is contained in:
+3
-1
@@ -339,7 +339,9 @@ class ActiveQuery extends Component implements ISqlBuilder
|
|||||||
{
|
{
|
||||||
$sql = $this->builder->delete();
|
$sql = $this->builder->delete();
|
||||||
if ($getSql === FALSE) {
|
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;
|
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
|
* @return static
|
||||||
*/
|
*/
|
||||||
|
|||||||
+2
-2
@@ -108,10 +108,10 @@ class Command extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool|array|null
|
* @return mixed
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function fetchColumn(): null|bool|array
|
public function fetchColumn(): mixed
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this->prepare()->fetchColumn(PDO::FETCH_ASSOC);
|
return $this->prepare()->fetchColumn(PDO::FETCH_ASSOC);
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ class Model extends Base\Model
|
|||||||
} else {
|
} else {
|
||||||
$result = static::deleteByCondition($this->_attributes);
|
$result = static::deleteByCondition($this->_attributes);
|
||||||
}
|
}
|
||||||
|
$this->optimize();
|
||||||
return $this->afterDelete($result);
|
return $this->afterDelete($result);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ interface ModelInterface
|
|||||||
public static function findOne(array|string|int $param, $db = NULL): ?static;
|
public static function findOne(array|string|int $param, $db = NULL): ?static;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function optimize(): mixed;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $param
|
* @param int $param
|
||||||
* @param null $db
|
* @param null $db
|
||||||
|
|||||||
Reference in New Issue
Block a user