本文整理汇总了PHP中MongoCollection::createDBRef方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCollection::createDBRef方法的具体用法?PHP MongoCollection::createDBRef怎么用?PHP MongoCollection::createDBRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection::createDBRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareWriteData
/**
* Do any data prep tasks, such as converting Links to DBRefs.
*
* @param array $data
* The array of data.
*/
protected function prepareWriteData(array &$data)
{
foreach ($data as $key => $value) {
if (is_object($value) && $value instanceof Link) {
$data[$key] = $this->collection->createDBRef($value->getTarget());
}
}
}
示例2: testCreateDBRef
public function testCreateDBRef()
{
$ref = $this->object->createDBRef(array('foo' => 'bar'));
$this->assertEquals($ref, null);
$arr = array('_id' => new MongoId());
$ref = $this->object->createDBRef($arr);
$this->assertNotNull($ref);
$this->assertTrue(is_array($ref));
$arr = 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));
}
示例3: createThreadMetadata
/**
* Sets the metadata array on the thread.
*
* By default, Mongo will not include "$db" when creating the participant
* reference. We'll add that manually to be consistent with Doctrine.
*
* @param array &$thread
*/
private function createThreadMetadata(array &$thread)
{
$metadata = array();
$participantIds = array_keys($thread['datesOfLastMessageWrittenByOtherParticipant'] + $thread['datesOfLastMessageWrittenByParticipant'] + $thread['isDeletedByParticipant']);
foreach ($participantIds as $participantId) {
$meta = array('isDeleted' => false, 'participant' => $this->participantCollection->createDBRef(array('_id' => new \MongoId($participantId))) + array('$db' => (string) $this->participantCollection->db));
if (isset($thread['isDeletedByParticipant'][$participantId])) {
$meta['isDeleted'] = $thread['isDeletedByParticipant'][$participantId];
}
if (isset($thread['datesOfLastMessageWrittenByOtherParticipant'][$participantId])) {
$meta['lastMessageDate'] = new \MongoDate($thread['datesOfLastMessageWrittenByOtherParticipant'][$participantId]);
}
if (isset($thread['datesOfLastMessageWrittenByParticipant'][$participantId])) {
$meta['lastParticipantMessageDate'] = new \MongoDate($thread['datesOfLastMessageWrittenByParticipant'][$participantId]);
}
$metadata[] = $meta;
}
$thread['metadata'] = $metadata;
}
示例4: createDBRef
/**
* Wrapper method for MongoCollection::createDBRef().
*
* @see http://php.net/manual/en/mongocollection.createdbref.php
* @param mixed $documentOrId
* @return array
*/
public function createDBRef($documentOrId)
{
return $this->mongoCollection->createDBRef($documentOrId);
}
示例5: doCreateDBRef
protected function doCreateDBRef(array $a)
{
return $this->mongoCollection->createDBRef($a);
}