From 776859b3c8efd3c00a5f5f31b1ceb5eb30de317d Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Tue, 5 Aug 2014 13:09:48 +0400 Subject: [PATCH] fix count method with saving original sql expression --- Model/SqlCriteria.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Model/SqlCriteria.php b/Model/SqlCriteria.php index 287ed92..7636f40 100644 --- a/Model/SqlCriteria.php +++ b/Model/SqlCriteria.php @@ -81,9 +81,11 @@ class SqlCriteria public function count($select = 'x') { - $sql_expression_backup = $this->sql_expression; - $this->select($select); $this->defineJoinExpressions(); + $sql_expression_backup = $this->sql_expression; + if ($select) { + $this->select( $select ); + } if (!$this->sql_expression) { $this->sql_expression = 'SELECT COUNT(*) as count FROM :table'; }