PHP连接mongodb的简单范例,改代码简单演示了php如何链接到本地mongodb数据库,并检索其中一个表的数据
$connection = new Mongo( “localhost:27017” ); $collection = $connection->mydb->mycollection; $cursor = $collection->find(); foreach ($cursor as $id => $value) { echo “$id: “; var_dump( $value ); }