Исправление ошибки в SqlCriteria.count()

This commit is contained in:
2014-09-26 18:44:35 +04:00
parent b4c3d89020
commit b7ff8ab3fc
2 changed files with 4 additions and 8 deletions

View File

@ -226,13 +226,12 @@ abstract class SqlModel extends Model
return new SqlResultProvider($result);
}
public function count($select = 'x', $distinct, $where,$heaving = null, $group_by = null, $sql_expression = null, $sql_expression_params = array(), $cache_key = null)
public function count($where, $heaving = null, $group_by = null, $sql_expression = null, $sql_expression_params = array(), $cache_key = null)
{
$select = $this->db->selectExpr($select, $distinct);
$where = $this->db->whereExpr($where);
$group_by = $this->db->groupByExpr($group_by);
$result = $this->query(
'SELECT COUNT(*) as count FROM (' .
'SELECT x.count FROM (' .
(($sql_expression) ? $sql_expression : ('SELECT * FROM ' . $this->identify($this->table())))
. (($where) ? (' WHERE ' . $where) : '')
. (($group_by) ? (' GROUP BY ' . $group_by) : '') . ') AS x',