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

Pdo::setGroup

Set group query

Description​

public self Pdo::setGroup( string $query )

Sets GROUP BY. The text is written into the SQL as it is: never put user input in it. Another call appends its text directly, without a comma, so give every column in one call.

Arguments​

NameData typeDefaultRemarks
$querystringColumns, separated by commas

Example​

Controller
$db = new \Fegg\Database\Pdo();

// Select category, count(*) AS n From "cms_news" Where "cms_news".valid = 1 Group By category
$rows = $db->setItem('category, count(*) AS n')->setGroup('category')->select('cms_news')->execute()->all();