gpt4 book ai didi

php - Mongodb安装

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:52:36 26 4
gpt4 key购买 nike

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";

?>

最佳答案

Yii2 提供类 yii\mongodb\Connection 用于 mongodb 连接。

检查下面的链接。

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

它将解决您的问题。

关于php - Mongodb安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29794713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com