Add group by support in sql criteria.

This commit is contained in:
Alexander Demidov
2013-10-29 16:42:33 +04:00
parent d019ae2450
commit 4878b32641
3 changed files with 39 additions and 1 deletions

View File

@ -159,6 +159,30 @@ abstract class SqlDbDriver extends DbDriver
}
/**
* @param mixed $group_by
* @return string
* @throws ErrorException
*/
public function groupByExpr($group_by)
{
if (empty($group_by)) {
return $group_by;
}
if (!is_array($group_by)) {
$group_by = array($group_by);
}
foreach ($group_by as &$term) {
if ($term instanceof DbExpr) {
$term = (string) $term;
} else {
$term = $this->quoteIdentifier($term);
}
}
return implode(',', $group_by);
}
/**
* @param $select array
* @param $distinct string|bool
* @return string