hasNext() public méthode

Checks if there are any more elements in this cursor
public hasNext ( ) : boolean
Résultat boolean Returns true if there is another element
 /**
  * Ensures that the <code>next</code> points to the correct item, possibly reading from the dbCursor.
  */
 private function initializeNextItem()
 {
     while (!$this->messagesToReturn->valid() && $this->dbCursor->hasNext()) {
         $cb = $this->callback;
         $this->messagesToReturn = new \ArrayIterator($cb($this->dbCursor->getNext(), $this->actualAggregateIdentifier));
     }
     $this->next = $this->messagesToReturn->current();
     $this->messagesToReturn->next();
 }
Exemple #2
0
 /**
  * Query termination method (Will execute the query)
  * @return mixed
  */
 public function next()
 {
     if (!$this->_Cursor) {
         $this->_do_query();
     }
     if ($this->_Cursor && $this->_Cursor->hasNext()) {
         $document = $this->_Cursor->getNext();
         $this->_callback($document);
         return $document;
     }
 }
Exemple #3
0
 /**
  * @param \MongoCursor $cursor Mongo cursor instance to fetch data from.
  * @param boolean $all whether to fetch all rows or only first one.
  * @param string|callable $indexBy value to index by.
  * @return array|boolean result.
  * @see Query::fetchRows()
  */
 protected function fetchRowsInternal($cursor, $all, $indexBy)
 {
     $result = [];
     if ($all) {
         foreach ($cursor as $row) {
             if ($indexBy !== null) {
                 if (is_string($indexBy)) {
                     $key = $row[$indexBy];
                 } else {
                     $key = call_user_func($indexBy, $row);
                 }
                 $result[$key] = $row;
             } else {
                 $result[] = $row;
             }
         }
     } else {
         if ($cursor->hasNext()) {
             $result = $cursor->getNext();
         } else {
             $result = false;
         }
     }
     return $result;
 }
Exemple #4
0
 /**
  * hasNext.
  */
 public function hasNext()
 {
     $this->logQuery();
     return parent::hasNext();
 }
Exemple #5
0
 /**
  * Whether there is a next result.
  * @return boolean
  */
 public function hasNext()
 {
     return $this->cursor->hasNext();
 }
 /**
  * Assign every retrived record with collection's recordClass.
  *
  * @param \MongoCursor $cursor
  */
 private function instantiateRecordClass(\MongoCursor $cursor)
 {
     $recordClass = $this->recordClass();
     switch ($recordClass) {
         case null:
             while ($cursor->hasNext()) {
                 (yield $cursor->getNext());
             }
             break;
         default:
             while ($cursor->hasNext()) {
                 (yield new $recordClass($cursor->getNext()));
             }
             break;
     }
 }
Exemple #7
0
 /**
  * 检查是否还有下一项
  * @return Boolean
  */
 public function hasNext()
 {
     return $this->oMongoCursor->hasNext();
 }