メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

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​

NameData typeDefaultRemarks
$querystringCondition with ? placeholders
...$parametersmixedOne 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();