예제 #1
0
 public function testSetUseIdentifierKeys()
 {
     $cursor = $this->getMockCursor();
     $cursor->expects($this->at(0))->method('setUseIdentifierKeys')->with(true);
     $cursor->expects($this->at(1))->method('setUseIdentifierKeys')->with(false);
     $eagerCursor = new EagerCursor($cursor);
     $eagerCursor->setUseIdentifierKeys(true);
     $eagerCursor->setUseIdentifierKeys(false);
 }
예제 #2
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;
 }