【问题标题】:MongoDB\Driver\Exception\InvalidArgumentException in codeigniter 3.xcodeigniter 3.x 中的 MongoDB\Driver\Exception\InvalidArgumentException
【发布时间】:2018-06-22 10:56:39
【问题描述】:

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

消息:无法解析 MongoDB URI:'mongodb://'。无效的主机 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 mongodb codeigniter-3


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-24
    • 2019-04-10
    • 1970-01-01
    • 2023-03-28
    • 2016-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多