modify
This commit is contained in:
@@ -313,8 +313,11 @@ class ActiveQuery extends Component implements ISqlBuilder
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @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();
|
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
|
* @param $attributes
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ trait QueryTrait
|
|||||||
public ?int $offset = NULL;
|
public ?int $offset = NULL;
|
||||||
public ?int $limit = NULL;
|
public ?int $limit = NULL;
|
||||||
public string $group = '';
|
public string $group = '';
|
||||||
public string|Closure|ActiveQuery $from = '';
|
public string|Closure|ActiveQuery|null $from = '';
|
||||||
public string $alias = 't1';
|
public string $alias = 't1';
|
||||||
public array $filter = [];
|
public array $filter = [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user