doujilou3903 2016-12-07 05:55
浏览 81

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

I need to set a timeout for MongoDB Codeigniter Connection. My config file is

          $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?

  • 写回答

1条回答 默认 最新

  • dousonghs58612 2016-12-07 07:39
    关注

    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);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计