鍍金池/ 問答/PHP  數(shù)據(jù)庫/ 使用Mongodb的php擴(kuò)展進(jìn)行條件查詢,findOne有數(shù)據(jù)但是find沒有

使用Mongodb的php擴(kuò)展進(jìn)行條件查詢,findOne有數(shù)據(jù)但是find沒有數(shù)據(jù),求解答?

在使用Mongodb的php擴(kuò)展進(jìn)行查詢的時候,遇到如下問題,findOne進(jìn)行查詢一條的時候是能正常進(jìn)行返回的,但是使用find進(jìn)行多條查詢的時候,是沒有正常返回的,求大神指教!

<?php

require_once DIR . "/vendor/autoload.php";

$mongodb = new MongoDBDriverManager("mongodb://root:root@192.168.1.121:27017/gs_db1");
$collection = new MongoDB\Collection($mongodb,'gs_db1','userid');
$options = ['projection' =>['userid'=>1,'usercode'=>1],

        'limit'=>100,
        'skip'=>0,
        ];

//為什么這個就查不出來
$dataList = $collection->find(['userid' =>['$lte'=>'2000000']],$options);
//查的出來
$dataList1 = $collection->findOne(['userid' =>['$lte'=>'2000000']],$options);
print_r($dataList);
print_r($dataList1);

回答
編輯回答
離夢

find之后的數(shù)據(jù)是要要進(jìn)行處理的,iterator_to_array

2017年7月15日 04:40