Skip to content

Commit 352e1b6

Browse files
committedJun 3, 2017
Merge pull request #492 from daniel-aranda/model_cast_count_as_integer
Model cast count as integer
2 parents 1523023 + 8bfb68b commit 352e1b6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎lib/Model.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ public static function count(/* ... */)
15411541
$table = static::table();
15421542
$sql = $table->options_to_sql($options);
15431543
$values = $sql->get_where_values();
1544-
return static::connection()->query_and_fetch_one($sql->to_s(),$values);
1544+
return (int) static::connection()->query_and_fetch_one($sql->to_s(),$values);
15451545
}
15461546

15471547
/**

‎test/ActiveRecordFindTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ public function test_fetch_all()
226226

227227
public function test_count()
228228
{
229-
$this->assert_equals(1,Author::count(1));
230-
$this->assert_equals(2,Author::count(array(1,2)));
229+
$this->assert_same(1,Author::count(1));
230+
$this->assert_same(2,Author::count(array(1,2)));
231231
$this->assert_true(Author::count() > 1);
232-
$this->assert_equals(0,Author::count(array('conditions' => 'author_id=99999999999999')));
233-
$this->assert_equals(2,Author::count(array('conditions' => 'author_id=1 or author_id=2')));
234-
$this->assert_equals(1,Author::count(array('name' => 'Tito', 'author_id' => 1)));
232+
$this->assert_same(0,Author::count(array('conditions' => 'author_id=99999999999999')));
233+
$this->assert_same(2,Author::count(array('conditions' => 'author_id=1 or author_id=2')));
234+
$this->assert_same(1,Author::count(array('name' => 'Tito', 'author_id' => 1)));
235235
}
236236

237237
public function test_gh149_empty_count()

0 commit comments

Comments
 (0)
Please sign in to comment.