コード例 #1
0
ファイル: Cursor.php プロジェクト: cosmow/riak
 /**
  * Recreates the internal RiakCursor.
  */
 public function recreate()
 {
     $this->riakCursor = $this->collection->getRiakCollection()->find($this->query, $this->fields);
     if ($this->hint !== null) {
         $this->riakCursor->hint($this->hint);
     }
     if ($this->immortal !== null) {
         $this->riakCursor->immortal($this->immortal);
     }
     foreach ($this->options as $key => $value) {
         $this->riakCursor->addOption($key, $value);
     }
     if ($this->batchSize !== null) {
         $this->riakCursor->batchSize($this->batchSize);
     }
     if ($this->limit !== null) {
         $this->riakCursor->limit($this->limit);
     }
     if ($this->skip !== null) {
         $this->riakCursor->skip($this->skip);
     }
     if ($this->slaveOkay !== null) {
         $this->setRiakCursorSlaveOkay($this->slaveOkay);
     }
     // Set read preferences after slaveOkay, since they may be more specific
     if ($this->readPreference !== null) {
         if ($this->readPreferenceTags !== null) {
             $this->riakCursor->setReadPreference($this->readPreference, $this->readPreferenceTags);
         } else {
             $this->riakCursor->setReadPreference($this->readPreference);
         }
     }
     if ($this->snapshot) {
         $this->riakCursor->snapshot();
     }
     if ($this->sort !== null) {
         $this->riakCursor->sort($this->sort);
     }
     if ($this->tailable !== null) {
         $this->riakCursor->tailable($this->tailable);
     }
     if ($this->timeout !== null) {
         $this->riakCursor->timeout($this->timeout);
     }
 }
コード例 #2
0
ファイル: GridFS.php プロジェクト: cosmow/riak
 /**
  * Execute the insert query and persist the GridFSFile if necessary.
  *
  * @see Collection::doInsert()
  * @param array $a
  * @param array $options
  * @return mixed
  */
 protected function doInsert(array &$a, array $options = array())
 {
     // If there is no file, perform a basic insertion
     if (!isset($a['file'])) {
         parent::doInsert($a, $options);
         return;
     }
     /* If the file is dirty (i.e. it must be persisted), delegate to the
      * storeFile() method. Otherwise, perform a basic insertion.
      */
     $file = $a['file'];
     // instanceof GridFSFile
     unset($a['file']);
     if ($file->isDirty()) {
         $this->storeFile($file, $a, $options);
     } else {
         parent::doInsert($a, $options);
     }
     $a['file'] = $file;
     return $a;
 }
コード例 #3
0
ファイル: Builder.php プロジェクト: cosmow/riak
 /**
  * Executes the aggregation pipeline
  *
  * @param array $options
  * @return Iterator
  */
 public function execute($options = array())
 {
     return $this->collection->aggregate($this->getPipeline(), $options);
 }
コード例 #4
0
ファイル: Query.php プロジェクト: cosmow/riak
 /**
  * Executes a closure with a temporary read preference on a database or
  * collection.
  *
  * @param Database|Collection $object
  * @param \Closure            $closure
  * @return mixed
  */
 private function withReadPreference($object, \Closure $closure)
 {
     if (!isset($this->query['readPreference'])) {
         return $closure();
     }
     $prevReadPref = $object->getReadPreference();
     $object->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);
     try {
         $result = $closure();
     } catch (\Exception $e) {
     }
     $prevTags = !empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : null;
     $object->setReadPreference($prevReadPref['type'], $prevTags);
     if (isset($e)) {
         throw $e;
     }
     return $result;
 }
コード例 #5
0
ファイル: LoggableCollection.php プロジェクト: cosmow/riak
 /**
  * @see Collection::validate()
  */
 public function validate($scanData = false)
 {
     $this->log(array('validate' => true, 'scanData' => $scanData));
     return parent::validate($scanData);
 }