Mongodb选择集合在php中不起作用

时间:2017-01-09 10:58:07

标签: php mongodb

我正在尝试从我的mongo db表(位置)获取数据 尝试使用mongo db的selectCollection()函数,但它给出了以下错误我是mongo db的新手,为什么我没有得到为什么这个错误 出错。

object(MongoCollection)#3 (2) { ["w"]=> int(1) ["wtimeout"]=> int(10000) } 

以下是我的PHP代码

<?php
$host = "xxxx";
$user = "xxxx";
$pass = "xxx";
$db = "xxxx";
$port = "xxxx";

$con = new MongoClient("mongodb://{$host}:{$port}");
$data = $con->selectDB($db);
if ($user != '' && $pass != '')
    $record=$data->authenticate($user, $pass);
$location = $data->selectCollection('location');
var_dump($location);die;   
?>

请先帮助我。

0 个答案:

没有答案