使用MongoDB PHP Library来操作mongodb数据库,
https://docs.mongodb.com/php-...
从MongoDB查询出来的是一个集合,我想把它转为数组,应该怎么做呢?
比如下面这个示例,我想把$cursor
转为数组:
$collection = (new MongoDB\Client)->test->zips;
$cursor = $collection->find(['city' => 'JERSEY CITY', 'state' => 'NJ']);
foreach ($cursor as $document) {
echo $document['_id'], "\n";
}
牧羊人nacy
冉冉说