【发布时间】:2017-06-29 15:54:35
【问题描述】:
我有 ubuntu 16.04、php7 和 mongo。
更新系统后,我的代码不起作用...我有一个新版本的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);
你能帮帮我吗?谢谢!
【问题讨论】: