See also: MongoDB\Collection::count()
See also: http://docs.mongodb.org/manual/reference/command/count/
Inheritance: implements Phalcon\Db\Adapter\MongoDB\Operation\Executable
示例#1
0
 /**
  * Gets the number of documents matching the filter.
  *
  * @see Count::__construct() for supported options
  *
  * @param array|object $filter Query by which to filter documents
  * @param array        $options Command options
  *
  * @return integer
  */
 public function count($filter = [], array $options = [])
 {
     if (!isset($options['readConcern'])) {
         $options['readConcern'] = $this->readConcern;
     }
     if (!isset($options['readPreference'])) {
         $options['readPreference'] = $this->readPreference;
     }
     $operation = new Count($this->databaseName, $this->collectionName, $filter, $options);
     $server = $this->manager->selectServer($options['readPreference']);
     return $operation->execute($server);
 }