count mongodb in php

count, mongodb, php

Solution

The new driver does not implement `$cursor->count()` use `$collection->count()` instead

$collection->count($filter)

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

Problem

I have a collection user which has 2 parameters (Username,paid), username is a string and paid is a string too, i should count how many users with the parameter paid="true" this is my 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 is an expert in mongo could help, thanks :)

Original source