Skip to content

Commit

Permalink
update classes to properly use DB::expr() (refs #4617)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeelot committed Oct 21, 2012
1 parent c2fc6f0 commit cb4be3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions classes/Kohana/ORM.php
Expand Up @@ -1518,7 +1518,7 @@ public function count_relations($alias, $far_keys = NULL)
{
if ($far_keys === NULL)
{
return (int) DB::select(array('COUNT("*")', 'records_found'))
return (int) DB::select(array(DB::expr('COUNT(*)'), 'records_found'))
->from($this->_has_many[$alias]['through'])
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
->execute($this->_db)->get('records_found');
Expand All @@ -1533,7 +1533,7 @@ public function count_relations($alias, $far_keys = NULL)
if ( ! $far_keys OR ! $this->_loaded)
return 0;

$count = (int) DB::select(array('COUNT("*")', 'records_found'))
$count = (int) DB::select(array(DB::expr('COUNT(*)'), 'records_found'))
->from($this->_has_many[$alias]['through'])
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys)
Expand Down Expand Up @@ -1641,7 +1641,7 @@ public function count_all()
$this->_build(Database::SELECT);

$records = $this->_db_builder->from(array($this->_table_name, $this->_object_name))
->select(array('COUNT("*")', 'records_found'))
->select(array(DB::expr('COUNT(*)'), 'records_found'))
->execute($this->_db)
->get('records_found');

Expand Down
2 changes: 1 addition & 1 deletion classes/Model/Auth/User.php
Expand Up @@ -110,7 +110,7 @@ public function unique_key_exists($value, $field = NULL)
$field = $this->unique_key($value);
}

return (bool) DB::select(array('COUNT("*")', 'total_count'))
return (bool) DB::select(array(DB::expr('COUNT(*)'), 'total_count'))
->from($this->_table_name)
->where($field, '=', $value)
->where($this->_primary_key, '!=', $this->pk())
Expand Down

0 comments on commit cb4be3a

Please sign in to comment.