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
Post a Comment