Browse Source

Fix count

namespace
Alexander Demidov 11 years ago
parent
commit
52de52a17a
  1. 5
      model/SqlCriteria.php

5
model/SqlCriteria.php

@ -83,9 +83,8 @@ class SqlCriteria
{
$this->defineJoinExpressions();
$sql_expression_backup = $this->sql_expression;
if ($this->sql_expression) {
$select = $this->model->getDb()->selectExpr($this->select, $this->distinct);
$this->sql_expression = str_replace($select, 'COUNT(*) as count', $this->sql_expression);
if ($this->sql_expression && !strstr('COUNT(*)', $this->sql_expression)) {
$this->sql_expression = preg_replace('#^SELECT .+ FROM#', 'SELECT COUNT(*) as count FROM', $this->sql_expression);
} else {
$this->sql_expression = 'SELECT COUNT(*) as count FROM :table';
}

Loading…
Cancel
Save