Skip to content
Permalink
Browse files

Renaming Query::total() to Query::count()

  • Loading branch information...
lorenzo committed Nov 18, 2013
1 parent 9cc7a05 commit 5b3e31e715be8f1104e16f0219bd0ae9033effcc
Showing with 9 additions and 12 deletions.
  1. +3 −6 Cake/Model/Behavior/CounterCacheBehavior.php
  2. +2 −2 Cake/ORM/Query.php
  3. +4 −4 Cake/Test/TestCase/ORM/QueryTest.php
@@ -71,11 +71,8 @@
* 'published' => true,
* 'user_id' => $entity->get('user_id')
* ]);
* return $query
* ->select(['count' => $query->count('*')], true)
* ->hydrate(false)
* ->first()['count'];
* }
* return $query->count();
* }
* ]
* ]
* }}}
@@ -194,6 +191,6 @@ protected function _getCount(array $config, array $conditions) {
$config['conditions'] = array_merge($conditions, $config['conditions']);
$query = $this->_table->find($findType, $config);
return $query->select(['count' => $query->count('*')], true)->hydrate(false)->first()['count'];
return $query->count();
}
}
@@ -626,8 +626,8 @@ public function first() {
*
* @return integer
*/
public function total() {
$query = $this->select(['count' => $this->count('*')], true)
public function count() {
$query = $this->select(['count' => $this->func()->count('*')], true)
->hydrate(false);
$query->mapReduce(null, null, true);
return $query->first()['count'];
@@ -1389,18 +1389,18 @@ public function testHydrateBelongsToCustomEntity() {
}
/**
* Test getting totals from queries.
* Test getting counts from queries.
*
* @return void
*/
public function testTotal() {
public function testCount() {
$table = TableRegistry::get('articles');
$result = $table->find('all')->total();
$result = $table->find('all')->count();
$this->assertEquals(3, $result);
$query = $table->find('all')
->where(['id >' => 1]);
$result = $query->total();
$result = $query->count();
$this->assertEquals(2, $result);
$result = $query->execute();

0 comments on commit 5b3e31e

Please sign in to comment.
You can’t perform that action at this time.