Browse Source

fix SqlCriteria count

namespace
Alexander Demidov 11 years ago
parent
commit
b7fcfcf476
  1. 5
      Model/SqlCriteria.php

5
Model/SqlCriteria.php

@ -82,7 +82,12 @@ class SqlCriteria
public function count() public function count()
{ {
$this->defineJoinExpressions(); $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'); $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; return $count;
} }

Loading…
Cancel
Save