3
namespace Upside\Db\SQL;
7
protected SQLStatement $sql;
9
protected HavingExpression $expression;
11
public function __construct(?SQLStatement $statement = null)
13
if ($statement === null) {
14
$statement = new SQLStatement();
17
$this->sql = $statement;
18
$this->expression = new HavingExpression($statement);
21
public function __clone()
23
$this->sql = clone $this->sql;
24
$this->expression = new HavingExpression($this->sql);
27
protected function add_condition(string|\Closure|Expression $column, ?\Closure $value = null, string $separator = 'AND'): static
29
if (($column instanceof \Closure) && $value === null) {
30
$this->sql->add_having_group_condition($column, $separator);
32
$expr = $this->expression->init($column, $separator);
41
public function get_sql_statement(): SQLStatement
46
public function having(string|\Closure|Expression $column, \Closure $value = null): static
48
return $this->add_condition($column, $value, 'AND');
51
public function andHaving(string|\Closure|Expression $column, ?\Closure $value = null): static
53
return $this->add_condition($column, $value, 'AND');
56
public function orHaving(string|\Closure|Expression $column, ?\Closure $value = null): static
58
return $this->add_condition($column, $value, 'OR');