如何在Codeigniter中配置多个数据库和使用故障转移

编程入门 行业动态 更新时间:2024-10-20 01:33:04
本文介绍了如何在Codeigniter中配置多个数据库和使用故障转移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Codeigniter3.0.4作为文档,条件是我无法配置多个数据库并使用'failover'=> array()。

I've used Codeigniter3.0.4 as the document provide I can't configure multiple database and using 'failover' => array().

我发现了错误您尚未选择要连接的数据库类型。如果我使用此选项,则在我的网站上

I found an errros You have not selected a database type to connect to. on my website if I used this options

$active_group = 'default'; $active_record = TRUE; $db['default']['failover'] = array( array( 'hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'com', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => TRUE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE ), array( 'hostname' => 'localhost2', 'username' => 'root', 'password' => '', 'database' => 'ABC', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => TRUE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE ) );

请帮助我该怎么做。

推荐答案

您必须设置数据库的默认/组配置。如果默认/组配置失败,则只有它会检查故障转移

You have to set the default/group configuration of database. If default/group configuration fails then only it'll check the failover

$db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'database_name', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => TRUE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array( array( 'hostname' => 'localhost1', 'username' => '', 'password' => '', 'database' => '', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => TRUE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE ), array( 'hostname' => 'localhost2', 'username' => '', 'password' => '', 'database' => '', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => TRUE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE ) ) );

更多推荐

如何在Codeigniter中配置多个数据库和使用故障转移

本文发布于:2023-10-23 05:44:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519967.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   故障   数据库   如何在   Codeigniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!