CodeIgniter和Parse Server的database.php设置

时间:2016-10-12 02:52:23

标签: php codeigniter parse-platform parse-server

有没有人使用过CodeIgniter + Parse Server?我想结合使用这两个,但我不知道如何处理database.php文件中的设置。

$active_group = 'default';
$active_record = TRUE;

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

1 个答案:

答案 0 :(得分:1)

您可以在codeigniter中使用多个数据库,只需在同一个文件database.php中添加以下行

$db['second_db']['hostname'] = 'localhost';
$db['second_db']['username'] = 'mysql_username';
$db['second_db']['password'] = 'mysql_password';
$db['second_db']['database'] = 'admin';  
// More config in same way, if required

访问默认数据库:

$this->load->database();
$query = $this->db->query();

访问第二个数据库

$second_db= $this->load->database('second_db', TRUE);
$query = $second_db->query();