CI: configure the multi-database access method and ci database access. CI: how to configure multi-database access. ci database access this article describes how to configure multi-database access for CI. I would like to share it with you for your reference. The details are as follows: 1. modify the dateba CI to configure multi-database access and ci database access
This example describes how to configure multi-database access for CI. We will share this with you for your reference. The details are as follows:
1. modify the datebase. php file:
$db['XXX']['pconnect'] = TRUE;
Modify:
$db['XXX']['pconnect'] = FALSE;
2. copy the original database link definition, as shown in the current
$ Db ['bbs '] ['hostname'] = 'Your database IP address'; $ db ['bbs'] ['username'] = 'Link username '; $ db ['bbs '] ['password'] = 'database connection password'; $ db ['bbs'] ['database'] = 'database name '; $ db ['bbs '] ['dbdriver'] = 'mysql'; $ db ['bbs '] ['dbprefix'] = 'cg _'; $ db ['bbs '] ['pconnect'] = FALSE; $ db ['bbs '] ['DB _ debug'] = TRUE; $ db ['bbs '] ['cache _ on'] = FALSE; $ db ['bbs'] ['cachedir'] = ''; $ db ['bbs '] ['char _ set'] = 'utf8'; $ db ['bbs'] ['dbcollat'] = 'utf8 _ general_ci '; $ db ['bbs '] ['swap _ pre'] = ''; $ db ['bbs'] ['autoinit '] = TRUE; $ db ['bbs '] ['stricton'] = FALSE;
The rest do not need to be modified, and then load the constructor in your controller:
Function _ construct () {parent ::__ construct (); $ this-> XXX = $ this-> load-> database ('XXX', TRUE ); // Note: Here XXX represents the bbs above. you can change it to bbs}
Usage:
$ Query = $ this-> bbs-> query ($ SQL); // same as before, here, $ this-> XXX is used as your defined bbs $ rs = $ query-> result ();