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

@ -206,11 +206,13 @@ abstract class SqlModel extends Model
{
$select = $this->db->selectExpr($select, $distinct);
$where = $this->db->whereExpr($where);
$group_by = $this->db->groupByExpr($group_by);
$order = isset($order['sort']) ? $this->order($order, $order['sort']) : false;
$limit = $this->db->limitExpr($limit);
$result_items = $this->fetchAll(
(($sql_expression) ? $sql_expression : ('SELECT ' . $select . ' FROM ' . $this->table()))
. (($where) ? (' WHERE ' . $where) : '')
. (($group_by) ? (' GROUP BY ' . $group_by) : '')
. (($order) ? ($order) : '')
. (($limit) ? (' LIMIT ' . $limit) : ''),
$sql_expression_params,