【问题标题】:Erorr multiple databases on codeignitercodeigniter 中的多个数据库出错
【发布时间】:2017-05-03 09:43:41
【问题描述】:

我正在尝试使用多个数据库构建一个项目我在项目中使用了3个数据库,有时应用程序运行正常但突然经常出现关于哪个数据库错误的警告错误?

Unable to connect to your database server using the provided settings.

Filename: C:/xampp/htdocs/sbc-portal/system/database/DB_driver.php

Line Number: 436

【问题讨论】:

  • 所有数据库都是mysql?
  • 是的,每个查询都出错,但后来又正常了,然后又出错了
  • 设置假持久连接,增加mysql最大连接限制
  • 我投票结束这个问题,因为这可能会导致不正确的Credentials

标签: php codeigniter mysqli


【解决方案1】:

对于辅助数据库添加以下代码

$db['otherdb']['hostname'] = "localhost";
$db['otherdb']['username'] = "root";
$db['otherdb']['password'] = "";
$db['otherdb']['database'] = "other_database_name";
$db['otherdb']['dbdriver'] = "mysql";
$db['otherdb']['dbprefix'] = "";
$db['otherdb']['pconnect'] = FALSE;
$db['otherdb']['db_debug'] = FALSE;
$db['otherdb']['cache_on'] = FALSE;
$db['otherdb']['cachedir'] = "";
$db['otherdb']['char_set'] = "utf8";
$db['otherdb']['dbcollat'] = "utf8_general_ci";
$db['otherdb']['swap_pre'] = "";
$db['otherdb']['autoinit'] = TRUE;
$db['otherdb']['stricton'] = FALSE;

然后连接到辅助数据库

$otherdb = $this->load->database('otherdb', TRUE);
$test= $otherdb->get('test');

希望它有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-19
    • 2010-10-12
    • 2012-01-06
    • 1970-01-01
    相关资源
    最近更新 更多