/** * Retrieve the collection object (as provided by x::find()) * @return Collection */ public function getNext() { $item = $this->cursor->getNext(); $obj = clone $this->collection; $obj->populate($item); return $obj; }
/** * Get next doc in cursor * @return EMongoDocument|null */ public function getNext() { if ($c = $this->cursor->getNext()) { return $this->current = $this->model->populateRecord($c, true, $this->partial); } return null; }
/** * 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(); }
/** * 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; } }
public function as_array($key = null, $value = null) { $return_value = array(); while ($data = parent::getNext()) { if ($key === null && $value === null) { $return_value[] = $this->load_model($data); } elseif ($key === null) { if (array_key_exists($value, $data)) { $return_value[] = $data[$value]; } } elseif ($value === null) { if (array_key_exists($key, $data)) { $return_value[$data[$key]] = $this->load_model($data); } } else { if (array_key_exists($key, $data) && array_key_exists($value, $data)) { $return_value[(string) $data[$key]] = $data[(string) $value]; } } } return $return_value; }
/** * @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) { $result[] = $row; } } else { if ($row = $cursor->getNext()) { $result = $row; } else { $result = false; } } return $result; }
/** * @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; }
/** * 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()); }
/** * getNext. */ public function getNext() { $this->logQuery(); return parent::getNext(); }
/** * 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; } }
/** * Return the next object to which this cursor points, and advance the cursor * * @throws \MongoConnectionException * @throws \MongoCursorTimeoutException * @return modelBase Returns the next object */ public function getNext() { $modelClass = $this->modelClass; $item = $this->cursor->getNext(); return isset($item) ? new $modelClass($item) : null; }
/** * Return the next file to which this cursor points, and advance the cursor * * @return MongoGridFSFile - Returns the next file. */ public function getNext() { parent::getNext(); return $this->current(); }
/** * 获取下一个值,并且把游标移动 * @return Array */ public function getNext() { return $this->oMongoCursor->getNext(); }