当前位置: 首页>>代码示例>>PHP>>正文


PHP MongoCursor::skip方法代码示例

本文整理汇总了PHP中MongoCursor::skip方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCursor::skip方法的具体用法?PHP MongoCursor::skip怎么用?PHP MongoCursor::skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCursor的用法示例。


在下文中一共展示了MongoCursor::skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
     }
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:37,代码来源:EMongoCursor.php

示例2: __construct

 /**
  * @param \MongoCursor $cursor
  * @param ODM          $odm
  * @param string|null  $class
  * @param array        $sort
  * @param int          $limit
  * @param int          $offset
  */
 public function __construct(\MongoCursor $cursor, ODM $odm, $class, array $sort = [], $limit = null, $offset = null)
 {
     $this->cursor = $cursor;
     $this->odm = $odm;
     $this->class = $class;
     !empty($sort) && $this->cursor->sort($sort);
     !empty($limit) && $this->cursor->limit($limit);
     !empty($offset) && $this->cursor->skip($offset);
 }
开发者ID:tuneyourserver,项目名称:components,代码行数:17,代码来源:DocumentCursor.php

示例3: getItems

 /**
  * Returns an array of items for a page.
  *
  * @param  int   $offset           Page offset
  * @param  int   $itemCountPerPage Number of items per page
  * @return array
  */
 public function getItems($offset, $itemCountPerPage)
 {
     //      $cursor = clone $this -> cursor;
     $this->cursor->skip($offset);
     $this->cursor->limit($itemCountPerPage);
     $resultSet = clone $this->resultSetPrototype;
     $resultSet->initialize($this->createResult($this->cursor));
     return $resultSet;
 }
开发者ID:pasechnik,项目名称:mongozend,代码行数:16,代码来源:MongoCursor.php

示例4: fetchData

 /**
  * @see CActiveDataProvider::fetchData()
  * @return array
  */
 public function fetchData()
 {
     $criteria = $this->getCriteria();
     // I have not refactored this line considering that the condition may have changed from total item count to here, maybe.
     $this->_builder = new EMongoQueryBuilder($this->model, isset($criteria['condition']) && is_array($criteria['condition']) ? $criteria['condition'] : [], isset($criteria['project']) && !empty($criteria['project']) ? $criteria['project'] : []);
     $this->options['condition'] = isset($criteria['condition']) && is_array($criteria['condition']) ? $criteria['condition'] : [];
     $this->options['projection'] = isset($criteria['project']) && !empty($criteria['project']) ? $criteria['project'] : [];
     // If we have sort and limit and skip setup within the incoming criteria let's set it
     if (isset($criteria['sort']) && is_array($criteria['sort'])) {
         $this->_builder->sort($criteria['sort']);
     }
     if (isset($criteria['skip']) && is_int($criteria['skip'])) {
         $this->_builder->skip($criteria['skip']);
     }
     if (isset($criteria['limit']) && is_int($criteria['limit'])) {
         $this->_builder->limit($criteria['limit']);
     }
     if (isset($criteria['hint']) && (is_array($criteria['hint']) || is_string($criteria['hint']))) {
         $this->_builder->hint($criteria['hint']);
     }
     if (($pagination = $this->getPagination()) !== false) {
         $pagination->setItemCount($this->getTotalItemCount());
         $this->_builder->limit($pagination->getLimit());
         $this->_builder->skip($pagination->getOffset());
     }
     if (($sort = $this->getSort()) !== false) {
         $sort = $sort->getOrderBy();
         if (count($sort) > 0) {
             $this->_builder->sort($sort);
         }
     }
     //                var_dump(iterator_to_array($this->_builder->find()));die;
     return $this->_builder->queryAll(true);
 }
开发者ID:yiicod,项目名称:mongoyii,代码行数:38,代码来源:EMongoDataProvider.php

示例5: skip

 /**
  * Skip the specified number of documents
  *
  * @since v1.0.0
  */
 public function skip($x = FALSE)
 {
     if ($x !== FALSE && is_numeric($x) && $x >= 1) {
         return $this->_cursor->skip((int) $x);
     }
     return $this->_cursor;
 }
开发者ID:AnthemiusGuo,项目名称:managerproject,代码行数:12,代码来源:Cimongo_cursor.php

示例6: skip

 /**
  * Wrapper method for MongoCursor::skip().
  *
  * @see http://php.net/manual/en/mongocursor.skip.php
  * @param integer $num
  * @return self
  */
 public function skip($num)
 {
     $num = (int) $num;
     $this->skip = $num;
     $this->mongoCursor->skip($num);
     return $this;
 }
开发者ID:ne0h12,项目名称:mongodb,代码行数:14,代码来源:Cursor.php

示例7: fetchData

 /**
  * @see CActiveDataProvider::fetchData()
  * @return array
  */
 public function fetchData()
 {
     $criteria = $this->getCriteria();
     // I have not refactored this line considering that the condition may have changed from total item count to here, maybe.
     $this->_cursor = $this->model->find(isset($criteria['condition']) && is_array($criteria['condition']) ? $criteria['condition'] : array(), isset($criteria['project']) && !empty($criteria['project']) ? $criteria['project'] : array());
     // If we have sort and limit and skip setup within the incoming criteria let's set it
     if (isset($criteria['sort']) && is_array($criteria['sort'])) {
         $this->_cursor->sort($criteria['sort']);
     }
     if (isset($criteria['skip']) && is_int($criteria['skip'])) {
         $this->_cursor->skip($criteria['skip']);
     }
     if (isset($criteria['limit']) && is_int($criteria['limit'])) {
         $this->_cursor->limit($criteria['limit']);
     }
     if (isset($criteria['hint']) && (is_array($criteria['hint']) || is_string($criteria['hint']))) {
         $this->_cursor->hint($criteria['hint']);
     }
     if (($pagination = $this->getPagination()) !== false) {
         $pagination->setItemCount($this->getTotalItemCount());
         $this->_cursor->limit($pagination->getLimit());
         $this->_cursor->skip($pagination->getOffset());
     }
     if (($sort = $this->getSort()) !== false) {
         $sort = $sort->getOrderBy();
         if (count($sort) > 0) {
             $this->_cursor->sort($sort);
         }
     }
     return iterator_to_array($this->_cursor, false);
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:35,代码来源:EMongoDataProvider.php

示例8: skip

 public function skip($offset)
 {
     if ($offset > 0 && $this->resource instanceof \MongoCursor) {
         return $this->resource->skip($offset);
     }
     return $this->resource;
 }
开发者ID:pasechnik,项目名称:mongozend,代码行数:7,代码来源:Result.php

示例9: getPaginator

 /**
  * Performs proper skip and limit to get
  * data package that can be wraped in paginator
  * 
  * @param int $perPage
  * @param int $page 
  * @param mixed $options Options you want to pass
  */
 public function getPaginator($perPage = 10, $page = 1, $options = null)
 {
     $this->_checkCursor();
     $total = $this->_cursor->count();
     $this->_cursor->skip(($page - 1) * $perPage)->limit($perPage);
     $result = $this->get();
     return $this->_createPaginator($result, $total, $perPage, $page, $options);
 }
开发者ID:sunkangtaichi,项目名称:PHPAPPLISTION_START,代码行数:16,代码来源:Mapper.php

示例10: _apply_cursor_controls

 /**
  * Apply the limit,skip,sort options to the cursor before iterating on documents
  */
 protected function _apply_cursor_controls()
 {
     if ($this->_Cursor) {
         if ($this->_cursor_controls['limit'] !== null) {
             $this->_Cursor->limit($this->_cursor_controls['limit']);
         }
         if ($this->_cursor_controls['skip'] !== null) {
             $this->_Cursor->skip($this->_cursor_controls['skip']);
         }
         if (!empty($this->_cursor_controls['sort'])) {
             $this->_Cursor->sort($this->_cursor_controls['sort']);
         }
     }
 }
开发者ID:alex-robert,项目名称:knot,代码行数:17,代码来源:Findr.php

示例11: configureCursor

 public function configureCursor()
 {
     if ($this->cursor === null) {
         return;
     }
     if ($this->getOffset() > -1) {
         $this->cursor->skip($this->getOffset());
     }
     if ($this->getLimit() > -1) {
         $this->cursor->limit($this->getLimit());
     }
     if ($this->getOrder() !== null) {
         $this->cursor->sort($this->getOrder());
     }
 }
开发者ID:edwardstock,项目名称:yii-mongo-record,代码行数:15,代码来源:MongoDbCriteria.php

示例12: getCursorFromQueryLog

 /**
  * Create MongoCursor from string query log
  *
  * @param string $queryString
  * @return \MongoCursor|null
  */
 protected function getCursorFromQueryLog($queryString)
 {
     $cursor = null;
     $connection = $this->panel->getDb();
     $connection->open();
     if ($connection->isActive) {
         $queryInfo = Json::decode($queryString);
         $query = $this->prepareQuery(isset($queryInfo['query']['$query']) ? $queryInfo['query']['$query'] : $queryInfo['query']);
         $cursor = new \MongoCursor($connection->mongoClient, $queryInfo['ns'], $query, $queryInfo['fields']);
         $cursor->limit($queryInfo['limit']);
         $cursor->skip($queryInfo['skip']);
         if (isset($queryInfo['query']['$orderby'])) {
             $cursor->sort($queryInfo['query']['$orderby']);
         }
     }
     return $cursor;
 }
开发者ID:miradnan,项目名称:yii2-mongodb,代码行数:23,代码来源:ExplainAction.php

示例13: getCursor

 /**
  * {@inheritDoc}
  */
 public function getCursor()
 {
     if (is_null($this->cursor)) {
         $rawCollection = $this->connection->getRaw()->{$this->collection->getName()};
         if (empty($this->criteria)) {
             $this->cursor = $rawCollection->find();
         } else {
             $this->cursor = $rawCollection->find($this->criteria);
         }
         if (isset($this->sorts)) {
             $this->cursor->sort($this->sorts);
         }
         if (isset($this->skip)) {
             $this->cursor->skip($this->skip);
         }
         if (isset($this->limit)) {
             $this->cursor->limit($this->limit);
         }
     }
     return $this->cursor;
 }
开发者ID:xinix-technology,项目名称:norm,代码行数:24,代码来源:MongoCursor.php

示例14: getCursor

 /**
  *
  * @return \MongoCursor
  */
 private function getCursor()
 {
     if ($this->cursor) {
         return $this->cursor;
     }
     $this->cursor = $this->collection->getMongoCollection()->find($this->expression->toArray(), $this->fields);
     if ($this->skip) {
         $this->cursor->skip($this->skip);
     }
     if ($this->limit) {
         $this->cursor->limit($this->limit);
     }
     if ($this->options['batchSize']) {
         $this->cursor->batchSize($this->options['batchSize']);
     }
     if ($this->options['clientTimeout']) {
         $this->cursor->timeout($this->options['clientTimeout']);
     }
     if ($this->options['serverTimeout']) {
         $this->cursor->maxTimeMS($this->options['clientTimeout']);
     }
     if ($this->sort) {
         $this->cursor->sort($this->sort);
     }
     if ($this->hint) {
         $this->cursor->hint($this->hint);
     }
     // log request
     if ($this->client->hasLogger()) {
         $this->client->getLogger()->debug(get_called_class() . ': ' . json_encode(array('collection' => $this->collection->getName(), 'query' => $this->expression->toArray(), 'project' => $this->fields, 'sort' => $this->sort)));
     }
     $this->cursor->rewind();
     // define read preferences
     if ($this->readPreference) {
         $this->cursor->setReadPreference($this->readPreference['type'], $this->readPreference['tagsets']);
     }
     return $this->cursor;
 }
开发者ID:paulocarvalhodesign,项目名称:php-mongo,代码行数:42,代码来源:Cursor.php

示例15: skip

 public function skip($num)
 {
     parent::skip($num);
     return $this;
 }
开发者ID:lisong,项目名称:incubator,代码行数:5,代码来源:Cursor.php


注:本文中的MongoCursor::skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。