如何连接多个数据库用户名randonly

时间:2018-05-12 20:22:55

标签: database codeigniter connection

任何人都可以让我知道如何整合这两行

$db_users = array('user1','user2', 'user3','user4','user5');
$db_user = $db_users[array_rand($db_users)];

使用下面的codeigniter数据库连接代码随机连接不同的用户名?

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'mydbuser',
    'password' => 'mydbpsw',
    'database' => 'mydb',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

0 个答案:

没有答案