本文整理匯總了PHP中ZurmoRedBean::count方法的典型用法代碼示例。如果您正苦於以下問題:PHP ZurmoRedBean::count方法的具體用法?PHP ZurmoRedBean::count怎麽用?PHP ZurmoRedBean::count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ZurmoRedBean
的用法示例。
在下文中一共展示了ZurmoRedBean::count方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testMultipleManyManysToTheSameModel
public function testMultipleManyManysToTheSameModel()
{
$pp1 = new PP();
$pp1->name = 'pp1a';
$pp1->save();
$this->assertTrue($pp1->save());
$pp1Id = $pp1->id;
$pp2 = new PP();
$pp2->name = 'pp2a';
$this->assertTrue($pp2->save());
$pp2Id = $pp2->id;
$p = new P();
$p->name = 'manyNames';
$p->ppManyAssumptive->add($pp1);
$p->ppManySpecific->add($pp2);
$this->assertTrue($p->save());
$pId = $p->id;
//Retrieve row to make sure columns are coppect
$row = ZurmoRedBean::getRow('select * from p');
$this->assertCount(5, $row);
$this->assertEquals(1, ZurmoRedBean::count('p_pp'));
$row = ZurmoRedBean::getRow('select * from p_pp');
$this->assertTrue(isset($row['p_id']) && ($row['p_id'] = $p->id));
$this->assertTrue(isset($row['pp_id']) && ($row['pp_id'] = $pp1->id));
$this->assertCount(3, $row);
$this->assertEquals(1, ZurmoRedBean::count('ppmanyspecificlink_p_pp'));
$row = ZurmoRedBean::getRow('select * from ppmanyspecificlink_p_pp');
$this->assertTrue(isset($row['p_id']) && ($row['p_id'] = $p->id));
$this->assertTrue(isset($row['pp_id']) && ($row['pp_id'] = $pp2->id));
$this->assertCount(3, $row);
//Unlink and make sure the tables are cleared
$p->forget();
$pp1->forget();
$pp2->forget();
$p = P::getById($pId);
$this->assertEquals(1, $p->ppManyAssumptive->count());
$this->assertEquals(1, $p->ppManySpecific->count());
$p->ppManyAssumptive->removeAll();
$p->ppManySpecific->removeAll();
$this->assertTrue($p->save());
$this->assertEquals(0, ZurmoRedBean::count('p_pp'));
$this->assertEquals(0, ZurmoRedBean::count('ppmanyspecificlink_p_pp'));
}