@ -81,9 +81,11 @@ class SqlCriteria
public function count($select = 'x')
{
$sql_expression_backup = $this->sql_expression;
$this->select($select);
$this->defineJoinExpressions();
if ($select) {
$this->select( $select );
}
if (!$this->sql_expression) {
$this->sql_expression = 'SELECT COUNT(*) as count FROM :table';