MongoCursor::hasNext PHP Method

hasNext() public method

Checks if there are any more elements in this cursor
public hasNext ( ) : boolean
return boolean Returns true if there is another element
    public function hasNext()
    {
        if (!$this->startedIterating) {
            $this->ensureIterator();
            $this->startedIterating = true;
            $this->storeIteratorState();
            $this->cursorNeedsAdvancing = false;
        } elseif ($this->cursorNeedsAdvancing) {
            $this->ensureIterator()->next();
            $this->cursorNeedsAdvancing = false;
        }
        return $this->ensureIterator()->valid();
    }

Usage Example

コード例 #1
0
 /**
  * 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();
 }
All Usage Examples Of MongoCursor::hasNext