本文整理汇总了PHP中MongoCollection::getDBRef方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCollection::getDBRef方法的具体用法?PHP MongoCollection::getDBRef怎么用?PHP MongoCollection::getDBRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection::getDBRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetDBRef
public function testGetDBRef()
{
for ($i = 0; $i < 50; $i++) {
$this->object->insert(array('x' => rand()));
}
$obj = $this->object->findOne();
$ref = $this->object->createDBRef($obj);
$obj2 = $this->object->getDBRef($ref);
$this->assertNotNull($obj2);
$this->assertEquals($obj['x'], $obj2['x']);
}
示例2: createThreadActiveParticipantArrays
/**
* Sets the active participant arrays on the thread.
*
* @see FOS\MessageBundle\Document\Thread::doEnsureActiveParticipantArrays()
* @param array $thread
*/
private function createThreadActiveParticipantArrays(array &$thread)
{
$activeParticipants = array();
$activeRecipients = array();
$activeSenders = array();
foreach ($thread['participants'] as $participantRef) {
foreach ($thread['metadata'] as $metadata) {
if ($participantRef['$id'] == $metadata['participant']['$id'] && $metadata['isDeleted']) {
continue 2;
}
}
$participantIsActiveRecipient = $participantIsActiveSender = false;
foreach ($thread['messages'] as $messageRef) {
$message = $this->threadCollection->getDBRef($messageRef);
if (null === $message) {
throw new \UnexpectedValueException(sprintf('Message "%s" not found for thread "%s"', $messageRef['$id'], $thread['_id']));
}
if (!isset($message['sender']['$id'])) {
throw new \UnexpectedValueException(sprintf('Sender reference not found for message "%s"', $messageRef['$id']));
}
if ($participantRef['$id'] == $message['sender']['$id']) {
$participantIsActiveSender = true;
} elseif (!$thread['isSpam']) {
$participantIsActiveRecipient = true;
}
if ($participantIsActiveRecipient && $participantIsActiveSender) {
break;
}
}
if ($participantIsActiveSender) {
$activeSenders[] = (string) $participantRef['$id'];
}
if ($participantIsActiveRecipient) {
$activeRecipients[] = (string) $participantRef['$id'];
}
if ($participantIsActiveSender || $participantIsActiveRecipient) {
$activeParticipants[] = (string) $participantRef['$id'];
}
}
$thread['activeParticipants'] = $activeParticipants;
$thread['activeRecipients'] = $activeRecipients;
$thread['activeSenders'] = $activeSenders;
}
示例3: getDBRef
/**
* getDBRef.
*/
public function getDBRef($ref)
{
$this->time->start();
$return = parent::getDBRef($ref);
$time = $this->time->stop();
$this->log(array('type' => 'getDBRef', 'ref' => $ref, 'time' => $time));
return $return;
}
示例4: doGetDBRef
protected function doGetDBRef(array $reference)
{
return $this->mongoCollection->getDBRef($reference);
}