Pdo::setHaving
Set having condition
Description
public self Pdo::setHaving( string $query, [ mixed ...$parameters ] )
Adds to the HAVING clause, used with setGroup. Parameters work as in setWhere: one per placeholder, and an array expands its placeholder.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $query | string | Condition with ? placeholders | |
| ...$parameters | mixed | One value (or array of values) per placeholder |
Example
Controller
$db = new \Fegg\Database\Pdo();
// Select category, count(*) AS n From "cms_news" Where "cms_news".valid = 1 Group By category Having count(*) > ?
$rows = $db->setItem('category, count(*) AS n')
->setGroup('category')
->setHaving('count(*) > ?', 3)
->select('cms_news')
->execute()
->all();