我希望将 MongoDB connectiontion 方法放入它自己的类中,但显然 new Mongo() 已经是一个类,那么我该怎么做呢?
$conn = new Mongo;
$db = $conn->thundergallery;
$grid = $db->getGridFS();
$file = $grid->findOne(array('unique_id' => $posted_id));
echo $file->getBytes();
exit;
$conn->close();
}catch(MongoConnectionException $e){
die('Error connecting to MongoDB server');
}catch(MongoException $e){
die('Error: ' . $e->getMessage());
}