qqq
This commit is contained in:
+7
-5
@@ -320,17 +320,19 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null $condition
|
* @param array|string|null $condition
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected static function deleteByCondition($condition = NULL, array $attributes = []): bool
|
protected static function deleteByCondition(array|string|null $condition = NULL, array $attributes = []): bool
|
||||||
{
|
{
|
||||||
$model = static::query();
|
$model = static::query()->bindParams($attributes);
|
||||||
if (!empty($condition)) {
|
if (is_array($condition)) {
|
||||||
$model->where($condition)->bindParams($attributes);
|
$model->where($condition);
|
||||||
|
} else if (is_string($condition)) {
|
||||||
|
$model->whereRaw($condition);
|
||||||
}
|
}
|
||||||
return (bool)$model->delete();
|
return (bool)$model->delete();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user