reset() публичный Метод

Clears the cursor
public reset ( ) : void
Результат void
Пример #1
0
 /**
  * The cursor constructor
  * @param string|EMongoDocument $modelClass - The class name for the active record
  * @param array|MongoCursor|EMongoCriteria $criteria -  Either a condition array (without sort,limit and skip) or a MongoCursor Object
  * @param array $fields
  */
 public function __construct($modelClass, $criteria = array(), $fields = array())
 {
     // If $fields has something in it
     if (!empty($fields)) {
         $this->partial = true;
     }
     if (is_string($modelClass)) {
         $this->modelClass = $modelClass;
         $this->model = EMongoDocument::model($this->modelClass);
     } elseif ($modelClass instanceof EMongoDocument) {
         $this->modelClass = get_class($modelClass);
         $this->model = $modelClass;
     }
     if ($criteria instanceof MongoCursor) {
         $this->cursor = $criteria;
         $this->cursor->reset();
     } elseif ($criteria instanceof EMongoCriteria) {
         $this->criteria = $criteria;
         $this->cursor = $this->model->getCollection()->find($criteria->condition, $criteria->project)->sort($criteria->sort);
         if ($criteria->skip > 0) {
             $this->cursor->skip($criteria->skip);
         }
         if ($criteria->limit > 0) {
             $this->cursor->limit($criteria->limit);
         }
     } else {
         // Then we are doing an active query
         $this->criteria = $criteria;
         $this->cursor = $this->model->getCollection()->find($criteria, $fields);
     }
 }
 /**
  * Returns the document at the specified index as an object
  *
  * @since v1.0.0
  */
 public function row($index = 0, $class = NULL, $as_object = FALSE)
 {
     $size = $this->_cursor->count();
     $this->_cursor->reset();
     $res = array();
     for ($i = 0; $i < $size; $i++) {
         $this->_cursor->next();
         if ($i == $index && $index <= $size) {
             $res = $as_object ? (object) $this->_cursor->current() : $this->_cursor->current();
             break;
         }
     }
     return $res;
 }
Пример #3
0
 /**
  * Wrapper method for MongoCursor::reset().
  *
  * @see http://php.net/manual/en/iterator.reset.php
  * @see http://php.net/manual/en/mongocursor.reset.php
  */
 public function reset()
 {
     $this->mongoCursor->reset();
 }
Пример #4
0
 /**
  *  Set Cursor
  *
  *  This method receive a MongoCursor and make
  *  it iterable. 
  *
  *  @param MongoCursor $obj 
  *
  *  @return void
  */
 protected final function setCursor(MongoCursor $obj)
 {
     $this->_cursor = $obj;
     $obj->reset();
     $this->setResult($obj->getNext());
 }
Пример #5
0
 /**
  * Clears the cursor
  * @link http://www.php.net/manual/en/mongocursor.reset.php
  * @return $this
  */
 public function reset()
 {
     $this->cursor->reset();
     return $this;
 }
Пример #6
0
 /**
  * 清除游标
  * @return null
  */
 public function reset()
 {
     return $this->oMongoCursor->reset();
 }