Permalink
Browse files

update classes to properly use DB::expr() (refs #4617)

  • Loading branch information...
1 parent c2fc6f0 commit cb4be3a6d9442ef9ab978c7306c5e0841e3d75d9 @Zeelot Zeelot committed Oct 21, 2012
Showing with 4 additions and 4 deletions.
  1. +3 −3 classes/Kohana/ORM.php
  2. +1 −1 classes/Model/Auth/User.php
View
@@ -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');
@@ -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)
@@ -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');
@@ -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())

0 comments on commit cb4be3a

Please sign in to comment.