本文整理汇总了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'));
}