@ -82,7 +82,12 @@ class SqlCriteria
public function count()
{
$this->defineJoinExpressions();
$sql_expression_backup = $this->sql_expression;
if (!$this->sql_expression) {
$this->sql_expression = 'SELECT COUNT(*) as count FROM :table';
}
$count = $this->model->count(array(), '', $this->where, null, $this->group_by, $this->sql_expression, $this->sql_expression_params)->fetchField('count');
$this->sql_expression = $sql_expression_backup;
return $count;