Skip to content

Commit

Permalink
Merge branch 'gh149' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
cvanschalkwijk committed Sep 12, 2011
2 parents a21e9fb + d1d68e7 commit a3c4601
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Model.php
Expand Up @@ -1404,7 +1404,7 @@ public static function count(/* ... */)
$options = static::extract_and_validate_options($args);
$options['select'] = 'COUNT(*)';

if (!empty($args))
if (!empty($args) && !is_null($args[0]) && !empty($args[0]))

This comment has been minimized.

Copy link
@dre1080

dre1080 Sep 17, 2011

You could just use !empty($args) && !empty($args[0]) since empty also checks that a value is null

{
if (is_hash($args[0]))
$options['conditions'] = $args[0];
Expand Down
7 changes: 7 additions & 0 deletions test/ActiveRecordFindTest.php
Expand Up @@ -226,6 +226,13 @@ public function test_count()
$this->assert_equals(1,Author::count(array('name' => 'Tito', 'author_id' => 1)));
}

public function test_gh149_empty_count()
{
$total = Author::count();
$this->assert_equals($total, Author::count(null));
$this->assert_equals($total, Author::count(array()));
}

public function test_exists()
{
$this->assert_true(Author::exists(1));
Expand Down

0 comments on commit a3c4601

Please sign in to comment.