queryNotIndexed() 공개 정적인 메소드

사용 중단: method was deprecated in 1.2 and will be removed in 2.0
public static queryNotIndexed ( string $className, string $unindexedFields ) : MongoDBException
$className string
$unindexedFields string
리턴 MongoDBException
예제 #1
0
파일: Query.php 프로젝트: noikiy/inovi
 /**
  * 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;
 }
예제 #2
0
 /**
  * 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;
 }