本文整理汇总了PHP中MongoCursor::hasNext方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCursor::hasNext方法的具体用法?PHP MongoCursor::hasNext怎么用?PHP MongoCursor::hasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCursor
的用法示例。
在下文中一共展示了MongoCursor::hasNext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeNextItem
/**
* 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();
}
示例2: 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;
}
}
示例3: fetchRowsInternal
/**
* @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;
}
示例4: hasNext
/**
* hasNext.
*/
public function hasNext()
{
$this->logQuery();
return parent::hasNext();
}
示例5: hasNext
/**
* Whether there is a next result.
* @return boolean
*/
public function hasNext()
{
return $this->cursor->hasNext();
}
示例6: instantiateRecordClass
/**
* 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;
}
}
示例7: hasNext
/**
* 检查是否还有下一项
* @return Boolean
*/
public function hasNext()
{
return $this->oMongoCursor->hasNext();
}