本文整理汇总了PHP中Mongo::createDBRef方法的典型用法代码示例。如果您正苦于以下问题:PHP Mongo::createDBRef方法的具体用法?PHP Mongo::createDBRef怎么用?PHP Mongo::createDBRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mongo
的用法示例。
在下文中一共展示了Mongo::createDBRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetDBRef
public function testGetDBRef()
{
$c = $this->object->selectCollection('foo');
$c->drop();
for ($i = 0; $i < 50; $i++) {
$c->insert((object) array('x' => rand()), array("safe" => true));
}
$obj = $c->findOne();
$ref = $this->object->createDBRef('foo', $obj);
$obj2 = $this->object->getDBRef($ref);
$this->assertNotNull($obj2);
$this->assertEquals($obj['x'], $obj2['x']);
}
示例2: testCreateDBRef
public function testCreateDBRef()
{
$arr = (object) array('_id' => new MongoId());
$ref = $this->object->createDBRef($arr);
$this->assertNotNull($ref);
$this->assertTrue(is_array($ref));
$arr = (object) array('_id' => 1);
$ref = $this->object->createDBRef($arr);
$this->assertNotNull($ref);
$this->assertTrue(is_array($ref));
$ref = $this->object->createDBRef(new MongoId());
$this->assertNotNull($ref);
$this->assertTrue(is_array($ref));
}