|
@ -79,17 +79,14 @@ class SqlCriteria |
|
|
return $this->model->find('', '', $this->where, null, null, null, null, 'DELETE FROM :table', $this->sql_expression_params)->affectedRows(); |
|
|
return $this->model->find('', '', $this->where, null, null, null, null, 'DELETE FROM :table', $this->sql_expression_params)->affectedRows(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function count($select = 'x') |
|
|
|
|
|
|
|
|
public function count($select = null) |
|
|
{ |
|
|
{ |
|
|
$this->defineJoinExpressions($select); |
|
|
$this->defineJoinExpressions($select); |
|
|
$sql_expression_backup = $this->sql_expression; |
|
|
$sql_expression_backup = $this->sql_expression; |
|
|
if ($select) { |
|
|
|
|
|
$this->select( $select ); |
|
|
|
|
|
} |
|
|
|
|
|
if (!$this->sql_expression) { |
|
|
if (!$this->sql_expression) { |
|
|
$this->sql_expression = 'SELECT COUNT(' . ($select ? $select : '*') . ') as count FROM :table'; |
|
|
$this->sql_expression = 'SELECT COUNT(' . ($select ? $select : '*') . ') as count FROM :table'; |
|
|
} |
|
|
} |
|
|
$count = $this->model->count($select, '', $this->where, null, $this->group_by, $this->sql_expression, $this->sql_expression_params)->fetchField('count'); |
|
|
|
|
|
|
|
|
$count = $this->model->count($this->where, null, $this->group_by, $this->sql_expression, $this->sql_expression_params)->fetchField('count'); |
|
|
$this->sql_expression = $sql_expression_backup; |
|
|
$this->sql_expression = $sql_expression_backup; |
|
|
return $count; |
|
|
return $count; |
|
|
} |
|
|
} |
|
|