Skip to content

Commit e1624ac

Browse files
authored
Merge pull request #44 from UseMuffin/query-count
Query::count() should always return integer.
2 parents d91ae04 + 11292cb commit e1624ac

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Query.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,19 +416,23 @@ public function applyOptions(array $options)
416416
/**
417417
* Returns the total amount of results for this query
418418
*
419-
* @return bool|int
419+
* @return int
420420
*/
421421
public function count()
422422
{
423423
if ($this->action() !== self::ACTION_READ) {
424-
return false;
424+
return 0;
425425
}
426426

427427
if (!$this->__resultSet) {
428428
$this->_execute();
429429
}
430430

431-
return $this->__resultSet->total();
431+
if ($this->__resultSet) {
432+
return $this->__resultSet->total();
433+
}
434+
435+
return 0;
432436
}
433437

434438
/**

tests/TestCase/QueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testAliasField()
5757

5858
public function testCountNonReadAction()
5959
{
60-
$this->assertEquals(false, $this->query->count());
60+
$this->assertEquals(0, $this->query->count());
6161
}
6262

6363
public function testCount()

0 commit comments

Comments
 (0)