简体   繁体   English

如何在CodeIgniter中设置MongoDB数据库连接超时?

[英]How to Set MongoDB database connection timeout in CodeIgniter?

I need to set a timeout for MongoDB Codeigniter Connection. 我需要为MongoDB Codeigniter连接设置超时。 My config file is 我的config文件是

          $config['mongo_db']['active'] = 'default';
          $config['mongo_db']['default']['no_auth'] = FALSE;
          $config['mongo_db']['default']['hostname'] = 'SHLY_DBSERVER';
          $config['mongo_db']['default']['port'] = '27018';
          $config['mongo_db']['default']['username'] = 'user';
          $config['mongo_db']['default']['password'] = '123';
          $config['mongo_db']['default']['database'] = 'testdb';
          $config['mongo_db']['default']['db_debug'] = TRUE;
          $config['mongo_db']['default']['return_as'] = 'array';
          $config['mongo_db']['default']['write_concerns'] = (int)1;
          $config['mongo_db']['default']['journal'] = TRUE;
          $config['mongo_db']['default']['read_preference'] = NULL;
          $config['mongo_db']['default']['read_preference_tags'] = NULL;
          $config['mongo_db']['default']['no_auth'] = FALSE;

is there any way to set that option from here? 有什么办法可以从这里设置该选项?

It's fixed with following manners like : 它通过以下方式修复:

$config['mongo_db']['timeout'] = 100 or -1;

Otherwise check like above syntax: 否则请检查类似上面的语法:

$cursor = $collection->find();
$cursor->timeout(-1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM