|
|
@ -79,16 +79,17 @@ class SqlCriteria |
|
|
|
return $this->model->find('', '', $this->where, null, null, null, null, 'DELETE FROM :table', $this->sql_expression_params)->affectedRows(); |
|
|
|
} |
|
|
|
|
|
|
|
//TODO: перенести определение sql_expression в модель
|
|
|
|
public function count($select = null) |
|
|
|
{ |
|
|
|
$this->defineJoinExpressions($select); |
|
|
|
$sql_expression_backup = $this->sql_expression; |
|
|
|
$select = 'COUNT(*) as count'; |
|
|
|
$select_parent_query = 'COUNT(*) as count'; |
|
|
|
if (!$this->sql_expression) { |
|
|
|
$this->sql_expression = 'SELECT COUNT(' . ($select ? $select : '*') . ') as count FROM :table'; |
|
|
|
$select = 'x.count'; |
|
|
|
$select_parent_query = 'x.count'; |
|
|
|
} |
|
|
|
$count = $this->model->count($select, $this->where, null, $this->group_by, $this->sql_expression, $this->sql_expression_params)->fetchField('count'); |
|
|
|
$count = $this->model->count($select_parent_query, $this->where, null, $this->group_by, $this->sql_expression, $this->sql_expression_params)->fetchField('count'); |
|
|
|
$this->sql_expression = $sql_expression_backup; |
|
|
|
return $count; |
|
|
|
} |
|
|
|