php - codeigniter 3.x 中的 MongoDB\Driver\Exception\InvalidArgumentException

标签 php mongodb codeigniter-3

将 CI 2.x 中的项目迁移到 3.x 后,在我使用 mongo db 的地方显示以下错误,这在 codeigniter 版本 2 中运行良好,

Message: Failed to parse MongoDB URI: 'mongodb://'. Invalid host string in URI.

数据库配置

// Generally will be localhost if you're querying from the machine that Mongo is installed on
$config['mongo_host'] = "localhost";
//$config['mongo_host'] = "xxxxxxxxx.compute.amazonaws.com";

// Generally will be 27017 unless you've configured Mongo otherwise
$config['mongo_port'] = 27017;

// The database you want to work from (required)
$config['mongo_db'] = "test_p1";

// Leave blank if Mongo is not running in auth mode
$config['mongo_user'] = "";
$config['mongo_pass'] = "";

// Persistant connections
$config['mongo_persist'] = TRUE;
$config['mongo_persist_key'] = 'ci_mongo_persist';

// Get results as an object instead of an array
$config['mongo_return'] = 'array'; // Set to object

// When you run an insert/update/delete how sure do you want to be that the database has received the query?
// safe = the database has receieved and executed the query
// fysnc = as above + the change has been committed to harddisk <- NOTE: will introduce a performance penalty
$config['mongo_query_safety'] = 'safe';

// Supress connection error password display
$config['mongo_supress_connect_error'] = TRUE;

// If you are having problems connecting try changing this to TRUE
$config['host_db_flag'] = FALSE;

最佳答案

您可能忘记在本地机器上设置数据库。

关于php - codeigniter 3.x 中的 MongoDB\Driver\Exception\InvalidArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50986406/

相关文章:

javascript - 将 javascript 变量传递到下一个 php 页面

node.js - 应如何设置高需求应用程序的 node.js 堆栈?

javascript - 如何将 JSON 对象数据的值填充到选择框中?

php - Codeigniter 随机注销用户?

php - 学说迁移 : altering a column to be nullable in production

php - 使用 group by 进行多个 mysql 查询

php - 插入每个数据不同的行 PDO

ruby-on-rails - MongoDB 中的受控数据分片

json - Spring boot 启动器数据休息,@Notnull 约束不起作用

php - 我什么时候应该转义 sql 查询