note 120922 added to class.mongodb-driver-cursor
| From: | peichi40233 at gmail dot com | Date: | Sun, 02 Apr 2017 09:32:50 +0000 |
| Subject: | note 120922 added to class.mongodb-driver-cursor | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208967@lists.php.net to get a copy of this message | ||
There used to be a count() method in the old mongo extension
(http://docs.php.net/manual/en/mongocursor.count.php), however, this feature seems to be deleted in
mongodb.
I've seen some people use executeCommand() to do that, but I found it much more earier to just
use the toArray() method and count the returned array.
For example:
$manager = new MongoDB\Driver\Manager();
$query = new MongoDB\Driver\Query($filter, $options);
$cursor = $manager->executeQuery('db.collection', $query)->toArray();
var_dump(count($cursor));
----
Server IP: 92.48.119.85
Probable Submitter: 111.255.173.130
----
Manual Page -- http://php.net/manual/en/class.mongodb-driver-cursor.php
Edit -- https://master.php.net/note/edit/120922
Del: integrated -- https://master.php.net/note/delete/120922/integrated
Del: useless -- https://master.php.net/note/delete/120922/useless
Del: bad code -- https://master.php.net/note/delete/120922/bad+code
Del: spam -- https://master.php.net/note/delete/120922/spam
Del: non-english -- https://master.php.net/note/delete/120922/non-english
Del: in docs -- https://master.php.net/note/delete/120922/in+docs
Del: other reasons-- https://master.php.net/note/delete/120922
Reject -- https://master.php.net/note/reject/120922
Search -- https://master.php.net/manage/user-notes.php