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


PHP MongoDBException::queryNotIndexed方法代码示例

本文整理汇总了PHP中Doctrine\ODM\MongoDB\MongoDBException::queryNotIndexed方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDBException::queryNotIndexed方法的具体用法?PHP MongoDBException::queryNotIndexed怎么用?PHP MongoDBException::queryNotIndexed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ODM\MongoDB\MongoDBException的用法示例。


在下文中一共展示了MongoDBException::queryNotIndexed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute the query and returns the results.
  *
  * @return mixed
  */
 public function execute()
 {
     $uow = $this->dm->getUnitOfWork();
     if ($this->isIndexRequired() && !$this->isIndexed()) {
         throw MongoDBException::queryNotIndexed($this->class->name, $this->getUnindexedFields());
     }
     $results = parent::execute();
     $hints = array();
     if ($this->refresh) {
         $hints[self::HINT_REFRESH] = true;
     }
     if ($this->query['slaveOkay'] === true) {
         $hints[self::HINT_SLAVE_OKAY] = true;
     }
     // Unwrap the BaseEagerCursor
     if ($results instanceof BaseEagerCursor) {
         $results = $results->getCursor();
     }
     // Convert the regular mongodb cursor to the odm cursor
     if ($results instanceof BaseCursor) {
         $results = $this->wrapCursor($results, $hints);
     }
     // Wrap odm cursor with EagerCursor if true
     if ($this->query['eagerCursor'] === true) {
         $results = new EagerCursor($results, $this->dm->getUnitOfWork(), $this->class);
     }
     // GeoLocationFindQuery just returns an instance of ArrayIterator so we have to
     // iterator over it and hydrate each object.
     if ($this->query['type'] === self::TYPE_GEO_LOCATION && $this->hydrate) {
         foreach ($results as $key => $result) {
             $document = $result['obj'];
             if ($this->class->distance) {
                 $document[$this->class->distance] = $result['dis'];
             }
             $results[$key] = $uow->getOrCreateDocument($this->class->name, $document, $hints);
         }
         $results->reset();
     }
     if ($this->primers) {
         $documentPersister = $this->dm->getUnitOfWork()->getDocumentPersister($this->class->name);
         foreach ($this->primers as $fieldName => $primer) {
             if ($primer) {
                 $documentPersister->primeCollection($results, $fieldName, $primer, $hints);
             }
         }
     }
     if ($this->hydrate && is_array($results) && isset($results['_id'])) {
         // Convert a single document array to a document object
         $results = $uow->getOrCreateDocument($this->class->name, $results, $hints);
     }
     return $results;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:57,代码来源:Query.php

示例2: execute

 /**
  * Execute the query and returns the results.
  *
  * @throws \Doctrine\ODM\MongoDB\MongoDBException
  * @return mixed
  */
 public function execute()
 {
     if ($this->isIndexRequired() && !$this->isIndexed()) {
         throw MongoDBException::queryNotIndexed($this->class->name, $this->getUnindexedFields());
     }
     $results = parent::execute();
     if (!$this->hydrate) {
         return $results;
     }
     $uow = $this->dm->getUnitOfWork();
     /* A geoNear command returns an ArrayIterator, where each result is an
      * object with "dis" (computed distance) and "obj" (original document)
      * properties. If hydration is enabled, eagerly hydrate these results.
      *
      * Other commands results are not handled, since their results may not
      * resemble documents in the collection.
      */
     if ($this->query['type'] === self::TYPE_GEO_NEAR) {
         foreach ($results as $key => $result) {
             $document = $result['obj'];
             if ($this->class->distance !== null) {
                 $document[$this->class->distance] = $result['dis'];
             }
             $results[$key] = $uow->getOrCreateDocument($this->class->name, $document, $this->unitOfWorkHints);
         }
         $results->reset();
     }
     /* If a single document is returned from a findAndModify command and it
      * includes the identifier field, attempt hydration.
      */
     if (($this->query['type'] === self::TYPE_FIND_AND_UPDATE || $this->query['type'] === self::TYPE_FIND_AND_REMOVE) && is_array($results) && isset($results['_id'])) {
         $results = $uow->getOrCreateDocument($this->class->name, $results, $this->unitOfWorkHints);
     }
     if (!empty($this->primers)) {
         $referencePrimer = new ReferencePrimer($this->dm, $uow);
         foreach ($this->primers as $fieldName => $primer) {
             $primer = is_callable($primer) ? $primer : null;
             $documents = $results instanceof Iterator ? $results : array($results);
             $referencePrimer->primeReferences($this->class, $documents, $fieldName, $this->unitOfWorkHints, $primer);
         }
     }
     return $results;
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:49,代码来源:Query.php


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