예제 #1
0
파일: Query.php 프로젝트: ne0h12/mongodb
 /**
  * Prepare the Cursor returned by {@link Query::execute()}.
  *
  * This method will apply cursor options present in the query structure
  * array. The Cursor may also be wrapped with an EagerCursor.
  *
  * @param Cursor $cursor
  * @return CursorInterface
  */
 protected function prepareCursor(Cursor $cursor)
 {
     /* Note: if this cursor resulted from a mapReduce command, applying the
      * read preference may be undesirable. Results would have been written
      * to the primary and replication may still be in progress.
      */
     if (isset($this->query['readPreference'])) {
         $cursor->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);
     }
     foreach ($this->getQueryOptions('hint', 'immortal', 'limit', 'skip', 'slaveOkay', 'sort', 'maxTimeMS') as $key => $value) {
         $cursor->{$key}($value);
     }
     if (!empty($this->query['snapshot'])) {
         $cursor->snapshot();
     }
     if (!empty($this->query['eagerCursor'])) {
         $cursor = new EagerCursor($cursor);
     }
     if (isset($this->query['useIdentifierKeys'])) {
         $cursor->setUseIdentifierKeys($this->query['useIdentifierKeys']);
     }
     return $cursor;
 }
예제 #2
0
파일: Cursor.php 프로젝트: im286er/ent
 /**
  * Wrapper method for MongoCursor::snapshot().
  *
  * @see \Doctrine\MongoDB\Cursor::snapshot()
  * @see http://php.net/manual/en/mongocursor.snapshot.php
  * @return self
  */
 public function snapshot()
 {
     $this->baseCursor->snapshot();
     return $this;
 }
예제 #3
0
 protected function prepareCursor(Cursor $cursor)
 {
     $cursor->limit($this->query['limit']);
     $cursor->skip($this->query['skip']);
     $cursor->sort($this->query['sort']);
     $cursor->immortal($this->query['immortal']);
     if (null !== $this->query['slaveOkay']) {
         $cursor->slaveOkay($this->query['slaveOkay']);
     }
     if ($this->query['snapshot']) {
         $cursor->snapshot();
     }
     foreach ($this->query['hints'] as $keyPattern) {
         $cursor->hint($keyPattern);
     }
     if ($this->query['eagerCursor'] === true) {
         $cursor = new EagerCursor($cursor);
     }
     return $cursor;
 }
예제 #4
0
 protected function prepareCursor(Cursor $cursor)
 {
     $cursor->limit($this->query['limit']);
     $cursor->skip($this->query['skip']);
     $cursor->sort($this->query['sort']);
     $cursor->immortal($this->query['immortal']);
     $cursor->slaveOkay($this->query['slaveOkay']);
     if ($this->query['snapshot']) {
         $cursor->snapshot();
     }
     foreach ($this->query['hints'] as $keyPattern) {
         $cursor->hint($keyPattern);
     }
 }