|
|
@ -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'; |
|
|
|
} |
|
|
|