本文整理汇总了PHP中MongoCursor::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCursor::reset方法的具体用法?PHP MongoCursor::reset怎么用?PHP MongoCursor::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCursor
的用法示例。
在下文中一共展示了MongoCursor::reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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);
}
}
示例2: row
/**
* 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: reset
/**
* 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: setCursor
/**
* 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: reset
/**
* Clears the cursor
* @link http://www.php.net/manual/en/mongocursor.reset.php
* @return $this
*/
public function reset()
{
$this->cursor->reset();
return $this;
}
示例6: reset
/**
* 清除游标
* @return null
*/
public function reset()
{
return $this->oMongoCursor->reset();
}