我有Ubuntu 16.04,php7和mongo。與php7 mongo查詢問題findOne
更新系統後,我的代碼不工作...我有一個新版本的PHP。
更新之前,我的代碼是:
// connect
$m = new MongoClient();
// select a database
$db = $m->clients;
// select a collection (analogous to a relational database's table)
$collection = $db->suscriptions;
// Check if exists in DB
$query = array('email' => $email);
$cursor = $collection->findOne($query);
更新後,我改變了連接由PHP文件指示,但我不能做任何查詢... 這是我的代碼,如果我刪除最後一行,代碼工作:
// connect
$m = new MongoDB\Driver\Manager("mongodb://localhost:27017");
// select a database
$db = $m->clients;
// select a collection (analogous to a relational database's table)
$collection = $db->suscriptions;
// Check if exists in DB
$query = array('email' => $email);
// Problem
$cursor = $collection->findOne($query);
你能幫我嗎?謝謝!
謝謝!完美的作品! – Miguel