modify
This commit is contained in:
@@ -313,8 +313,11 @@ class ActiveQuery extends Component implements ISqlBuilder
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete(): bool
|
||||
public function delete($getSql = false): string|bool
|
||||
{
|
||||
if ($getSql) {
|
||||
return $this->builder->delete();
|
||||
}
|
||||
return $this->execute($this->builder->all())->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,20 @@ class SqlBuilder extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$delete = sprintf('DELETE FROM %s ', $this->query->modelClass::getTable());
|
||||
|
||||
$this->query->from = null;
|
||||
|
||||
return $delete . $this->_prefix(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $attributes
|
||||
* @return array
|
||||
|
||||
@@ -34,7 +34,7 @@ trait QueryTrait
|
||||
public ?int $offset = NULL;
|
||||
public ?int $limit = NULL;
|
||||
public string $group = '';
|
||||
public string|Closure|ActiveQuery $from = '';
|
||||
public string|Closure|ActiveQuery|null $from = '';
|
||||
public string $alias = 't1';
|
||||
public array $filter = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user