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 :)
The new driver does not implement $cursor->count()
use $collection->count()
instead
$collection->count($filter)
in your case: $filter = array('paid' => 'true')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With