/** * 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; }
/** * 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; }
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; }
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); } }