count mongodb in php -


i have collection user has 2 parameters (username,paid), username string , paid string too, should count how many users parameter paid="true"

this try

<?php  $connection = new mongoclient(); $collection = $connection->ahmed->user;  $cursor = $collection->find(); var_dump($collection->count()); var_dump($collection->count($cursor->paid=>"true"))); ?> 

if there expert in mongo help, :)

the new driver not implement $cursor->count() use $collection->count() instead

$collection->count($filter) 

in case: $filter = array('paid' => 'true')


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -