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


PHP MongoCursor::count方法代码示例

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


在下文中一共展示了MongoCursor::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: count

 public function count($force = false)
 {
     if ($force || !isset($this->count)) {
         $this->count = $this->cursor->count();
     }
     return $this->count;
 }
开发者ID:mpcmf,项目名称:mpcmf-core,代码行数:7,代码来源:modelCursor.php

示例2: count

 /**
  * Returns the total number of rows in the result set.
  *
  * @return int
  */
 public function count()
 {
     if ($this->rowCount !== null) {
         return $this->rowCount;
     }
     $this->rowCount = $this->cursor->count($foundOnly = true);
     return $this->rowCount;
 }
开发者ID:pasechnik,项目名称:mongozend,代码行数:13,代码来源:MongoCursor.php

示例3: testDrop

 public function testDrop()
 {
     $this->object->storeFile('tests/somefile');
     $c = $this->object->chunks->count();
     $this->assertGreaterThan(0, $c);
     $this->assertEquals($this->count(), 1);
     $this->object->drop();
     $this->assertEquals($this->object->chunks->count(), 0);
     $this->assertEquals($this->object->count(), 0);
 }
开发者ID:redmeadowman,项目名称:mongo-php-driver,代码行数:10,代码来源:MongoGridFSTest.php

示例4: totalCount

 /**
  * Count total number of items without limit and offset
  * @return mixed
  */
 public function totalCount()
 {
     if (!$this->count) {
         $this->count = $this->cursor->count(false);
     }
     return $this->count;
 }
开发者ID:Nkelliny,项目名称:Framework,代码行数:11,代码来源:EntityCollection.php

示例5: getAffectedRows

 /**
  * Get affected rows
  *
  * @return int
  */
 public function getAffectedRows()
 {
     if ($this->resource instanceof \MongoCursor) {
         return $this->resource->count();
     }
     return $this->resource;
 }
开发者ID:pasechnik,项目名称:mongozend,代码行数:12,代码来源:Result.php

示例6: __construct

 /**
  * Construct by passing in the \MongoCursor and the object to populate
  * @param \MongoCursor $cursor
  */
 public function __construct(\MongoCursor $cursor, Collection $collection)
 {
     $this->cursor = $cursor;
     $this->count = $cursor->count(true);
     $this->position = 0;
     $this->collection = $collection;
 }
开发者ID:rogerthomas84,项目名称:ohdm,代码行数:11,代码来源:Cursor.php

示例7: count

 /**
  * Count the results from the query
  *
  * + Count the results from the current query: pass false for "all" results (disregard limit/skip)
  * + Count results of a separate query: pass an array or JSON string of query parameters
  *
  * @since   0.3.0
  *
  * See [\Countable::count]
  *
  * @link    http://www.php.net/manual/en/mongocursor.count.php \MongoCursor::count
  *
  * @param   boolean|array|string  $query
  *
  * @return  integer
  *
  * @throws  \Exception
  *
  * @uses    \JSON::encodeMongo
  * @uses    \JSON::decode
  * @uses    \Profiler::start
  * @uses    \Profiler::stop
  */
 public function count($query = true)
 {
     if (is_bool($query)) {
         // Profile count operation for cursor
         if ($this->getClientInstance()->profiling) {
             $this->benchmark = Profiler::start(get_class($this->getClientInstance()) . "::{$this->db}", $this->shellQuery() . ".count(" . JSON::encodeMongo($query) . ")");
         }
         $this->cursor || $this->load();
         $count = $this->cursor->count($query);
     } else {
         if (is_string($query) && $query[0] == "{") {
             $query = JSON::decode($query, true);
         }
         $query_trans = array();
         foreach ($query as $field => $value) {
             $query_trans[$this->getFieldName($field)] = $value;
         }
         $query = $query_trans;
         // Profile count operation for collection
         if ($this->getClientInstance()->profiling) {
             $this->benchmark = Profiler::start(get_class($this->getClientInstance()) . "::{$this->db}", "db.{$this->name}.count(" . ($query ? JSON::encodeMongo($query) : '') . ")");
         }
         $count = $this->getCollection()->count($query);
     }
     // End profiling count
     if ($this->benchmark) {
         // Stop the benchmark
         Profiler::stop($this->benchmark);
         // Clean benchmark token
         $this->benchmark = null;
     }
     return $count;
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:56,代码来源:Collection.php

示例8: 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

示例9: calculateTotalItemCount

 /**
  * @see CActiveDataProvider::calculateTotalItemCount()
  * @return int
  */
 public function calculateTotalItemCount()
 {
     if (!$this->_cursor) {
         $criteria = $this->getCriteria();
         $this->_cursor = $this->model->find(isset($criteria['condition']) && is_array($criteria['condition']) ? $criteria['condition'] : array());
     }
     return $this->_cursor->count();
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:12,代码来源:EMongoDataProvider.php

示例10: calculateTotalItemCount

 /**
  * @see CActiveDataProvider::calculateTotalItemCount()
  * @return int
  */
 public function calculateTotalItemCount()
 {
     if (!$this->_builder) {
         $criteria = $this->getCriteria();
         $this->_builder = new EMongoQueryBuilder($this->model, isset($criteria['condition']) && is_array($criteria['condition']) ? $criteria['condition'] : []);
     }
     return $this->_builder->count();
 }
开发者ID:yiicod,项目名称:mongoyii,代码行数:12,代码来源:EMongoDataProvider.php

示例11: count

 /**
  * Count the results
  *
  * @since v1.0.0
  */
 public function count($foundOnly = FALSE)
 {
     $count = array();
     try {
         $count = $this->_cursor->count($foundOnly);
     } catch (MongoCursorException $exception) {
         show_error($exception->getMessage(), 500);
     } catch (MongoConnectionException $exception) {
         show_error($exception->getMessage(), 500);
     } catch (MongoCursorTimeoutException $exception) {
         show_error($exception->getMessage(), 500);
     }
     return $count;
 }
开发者ID:AnthemiusGuo,项目名称:managerproject,代码行数:19,代码来源:Cimongo_cursor.php

示例12: count

 /**
  * count method on the cursor, allows to get result count
  *
  * @param bool $foundOnly
  * @return int
  */
 public function count($foundOnly = false)
 {
     return $this->myResultCursor->count($foundOnly);
 }
开发者ID:ppetermann,项目名称:king23,代码行数:10,代码来源:Result.php

示例13: count

 /**
  * Returns the number of documents found
  * {@see http://www.php.net/manual/en/mongocursor.count.php}
  * @param boolean $foundOnly default TRUE
  * @return integer count of documents found
  * @since v1.3.4
  */
 public function count($foundOnly = true)
 {
     return $this->_cursor->count($foundOnly);
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:11,代码来源:EMongoCursor.php

示例14: __construct

 /**
  * Constructor.
  *
  * @param  \Iterator $iterator Iterator to paginate
  * @throws \Zend\Paginator\Adapter\Exception\InvalidArgumentException
  */
 public function __construct(\MongoCursor $iterator)
 {
     $this->iterator = $iterator;
     $this->count = $iterator->count();
 }
开发者ID:antoinebon,项目名称:zf2,代码行数:11,代码来源:MongoCursor.php

示例15: createResult

 /**
  * @param  \MongoCursor $resource
  * @param  mixed        $context
  * @return Result
  */
 public function createResult($resource, $context = null)
 {
     $result = clone $this->resultPrototype;
     if ($resource instanceof \MongoCursor) {
         $rowCount = $resource->count($foundOnly = true);
     } elseif (is_array($resource) && isset($resource['n'])) {
         $rowCount = (int) $resource['n'];
         //            $resource = $this -> connection -> getDB() -> selectCollection( $context ) -> find( ['_id' => $this -> connection -> getLastGeneratedValue( $context ) ] );
     } else {
         $rowCount = (int) $resource;
         //            $resource = $this -> connection -> getDB() -> selectCollection( $context ) -> find( ['_id' => $this -> connection -> getLastGeneratedValue( $context ) ] );
     }
     $result->initialize($resource, $this->connection->getLastGeneratedValue($context), $rowCount);
     return $result;
 }
开发者ID:pasechnik,项目名称:mongozend,代码行数:20,代码来源:Mongo.php


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