Disucz multi-instance database code invocation.
Success stories based on Discuz 2.5
Modify conf/config_global.php
123456789 |
New database configuration information $_config[' db ' [' 2 '] [' dbhost '] = ' 192.168.1.2 '; $_config[' db ' [' 2 '] [' dbuser '] = ' root '; $_config[' db ' [' 2 ' [' dbpw '] = ' 123 '; $_config[' db ' [' 2 '] [' dbcharset '] = ' utf8 '; $_config[' db ' [' 2 '] [' pconnect '] = ' 0 '; $_config[' db '] [' 2 ' [' dbname '] = ' op '; $_config[' db ' [' 2 '] [' tablepre '] = ' op_ '; |
Modify source/class/class_core.php
12 |
Add classdb_biextendsdiscuz_database{} to the bottom line |
Copy soucrce/class/db_driver_mysql.php
Into db_driver_mysql_bi.php
Modifying the db_driver_mysql_bi.php
123456 |
Modify class name classdb_driver_mysql_bi.php//modify the serial number of the read configuration file $this->tablepre = $config [' 2 '] [' Tablepre '];// Set the identity information for connect functionconnect ($serverid = 2) { |
Referencing a new instance of database code operations
1234567 |
$driver = ' db_driver_mysql_op '; $_config=array (); @includeDISCUZ_ROOT. /config/config_global.php ';D b_bi::init ($driver, $_config[' DB '); $userinfo = Db_bi::fetch_first ("SELECT * from Op_users"); Var_dump ($userinfo); |
Discuz Multiple databases