/** * Set the HAVING clause * * @param mixed $having * @return Having */ public function having($having = null) { if (null !== $having) { if ($having instanceof Having) { $this->having = $having; } else { if (null === $this->having) { $this->having = (new Having($this->sql))->add($having); } else { $this->having->add($having); } } } if (null === $this->having) { $this->having = new Having($this->sql); } return $this; }
/** * A cláusula HAVING geralmente é utilizada com a cláusula GROUP BY para filtrar os resultados dos * valores agregados. Entretanto, HAVING pode ser especificada sem GROUP BY. A cláusula HAVING * especifica filtros adicionais aplicados após a cláusula WHERE ser filtrada. Esses filtros podem * ser aplicados a uma função de agregação utilizada na lista de seleção. * @param string $columnGroupBy * @param string $operador * @param string $valor * @param string $and_or * @return array $having */ public function having($columnGroupBy, $operador, $valor, $and_or = null) { if (empty($this->having)) { $having = new Having(); } $this->having = $having->add($columnGroupBy, $operador, $valor, $and_or); return $this->having; }