Mongodb安装在linux CentOS服务器(ssh)中,其中包含此URL中提到的步骤
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat/
使用该命令启动MongoDB服务器,状态正常。
sudo service mongod start
When connecting mongodb with PHP (Yii app), it shows error like this.
include(MongoClient.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
PHP code
<?php
// connect to mongodb
$m = new MongoClient();
echo "Connection to database successfully";
// select a database
$db = $m->health;
echo "Database mydb selected";
$collection = $db->medical;
echo "Collection selected succsessfully";
?>
答案 0 :(得分:1)
Yii2
为mongodb连接提供了课程yii\mongodb\Connection
。
检查以下链接。
http://www.yiiframework.com/doc-2.0/yii-mongodb-connection.html
Yii 2的MongoDb扩展
http://www.yiiframework.com/doc-2.0/ext-mongodb-index.html
它将解决您的问题。