本文整理汇总了PHP中Author::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::count方法的具体用法?PHP Author::count怎么用?PHP Author::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Author
的用法示例。
在下文中一共展示了Author::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGh149EmptyCount
public function testGh149EmptyCount()
{
$total = Author::count();
$this->assertEquals($total, Author::count(null));
$this->assertEquals($total, Author::count(array()));
}
示例2: test_count
public function test_count()
{
$this->assert_equals(1, Author::count(1));
$this->assert_equals(2, Author::count(array(1, 2)));
$this->assert_true(Author::count() > 1);
$this->assert_equals(0, Author::count(array('conditions' => 'author_id=99999999999999')));
$this->assert_equals(2, Author::count(array('conditions' => 'author_id=1 or author_id=2')));
$this->assert_equals(1, Author::count(array('name' => 'Tito', 'author_id' => 1)));
}
示例3: test_gh149_empty_count
public function test_gh149_empty_count()
{
$total = Author::count();
$this->assert_equals($total, Author::count(null));
$this->assert_equals($total, Author::count(array()));
}
示例4: test_transaction_rolledback_by_throwing_exception
public function test_transaction_rolledback_by_throwing_exception()
{
$original = Author::count();
$exception = null;
try {
Author::transaction(function () {
Author::create(array("name" => "blah"));
throw new Exception("blah");
});
} catch (Exception $e) {
$exception = $e;
}
$this->assert_not_null($exception);
$this->assert_equals($original, Author::count());
}
示例5: testTransactionRolledbackByThrowingException
public function testTransactionRolledbackByThrowingException()
{
$original = Author::count();
$exception = null;
try {
Author::transaction(function () {
Author::create(array("name" => "blah"));
throw new Exception("blah");
});
} catch (Exception $e) {
$exception = $e;
}
$this->assertNotNull($exception);
$this->assertEquals($original, Author::count());
}