From d1c8ecf85013366c5fa31abe056a2cda876e1d75 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Thu, 10 Apr 2014 15:30:09 +0400 Subject: [PATCH] Modifie SqlCriteria.count() - force to use custom sql_expression. --- model/SqlCriteria.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/model/SqlCriteria.php b/model/SqlCriteria.php index 9328f7b..72c8b23 100644 --- a/model/SqlCriteria.php +++ b/model/SqlCriteria.php @@ -80,7 +80,11 @@ class SqlCriteria public function count() { - $this->sql_expression = 'SELECT COUNT(*) as count FROM :table'; + if ($this->sql_expression && strpos($this->sql_expression, 'COUNT(*) as count')) { + ; + } else { + $this->sql_expression = 'SELECT COUNT(*) as count FROM :table'; + } $this->defineJoinExpressions(); return $this->model->find(array(), '', $this->where, null, null, null, null, $this->sql_expression, $this->sql_expression_params)->fetchField('count'); }