当前位置: 首页>>代码示例>>PHP>>正文


PHP MongoCollection::getDBRef方法代码示例

本文整理汇总了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']);
 }
开发者ID:salathe,项目名称:mongo-php-driver,代码行数:11,代码来源:MongoCollectionTest.php

示例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;
 }
开发者ID:gpuck,项目名称:FOSMessageBundle,代码行数:49,代码来源:MongoDBMigrateMetadataCommand.php

示例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;
 }
开发者ID:hybr,项目名称:jpm,代码行数:11,代码来源:LoggableMongoCollection.php

示例4: doGetDBRef

 protected function doGetDBRef(array $reference)
 {
     return $this->mongoCollection->getDBRef($reference);
 }
开发者ID:rybakit,项目名称:mongodb,代码行数:4,代码来源:Collection.php


注:本文中的MongoCollection::getDBRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。