php - Error Using Multiple Database In CodeIgniter -


I am trying to implement multiple databases in CI. My code is here:

 < Code> // database.php $ active_group = "default"; $ Active_record = TRUE; $ Db ['default'] ['hostname'] = "localhost"; $ Db ['default'] ['username'] = "original"; $ Db ['default'] ['password'] = "root"; $ Db ['default'] ['database'] = "revx"; $ Db ['default'] ['dbdriver'] = "MySQL"; $ Db ['default'] ['dbipfix'] = "rvx_"; $ Db ['default'] ['pconnect'] = true; $ Db ['default'] ['db_debug'] = true; $ Db ['default'] ['cache_on'] = falls; $ Db ['default'] ['cachered'] = ""; $ Db ['default'] ['char_set'] = "UTF8"; $ Db ['default'] ['dccillet'] = "utf 8_ggri_c"; $ Db ['smf'] ['hostname'] = "localhost"; $ Db ['smf'] ['username'] = "root"; $ Db ['smf'] ['password'] = "root"; $ Db ['smf'] ['database'] = "smf"; $ Db ['smf'] ['dbdr'] = "myself"; $ Db ['smf'] ['dbprefix'] = "smf_"; $ Db ['smf'] ['pconnect'] = true; $ Db ['smf'] ['db_debug'] = true; $ Db ['smf'] ['cache_on'] = false; $ Db ['smf'] ['cachered'] = ""; $ Db ['smf'] ['char_set'] = "UTF8"; $ DB ['SMF'] ['DBCOL'] = "UTF 8GGRL_C";  

is the model

  // user_model.php class user_model model {private $ ravelex_db; Function user_model () {origin: model (); $ This- & gt; Ravelex_db = $ this- & gt; Load-> Database ('default', TRUE); } Find_all function (print_r ($ this-> ravelex_db); $ Q = $ this- & gt; Ravelex_db-> Receive ('user'); Return $ q- & gt; result (); }} //smf_user_model.php class smf_user_model model {private $ smf_db; Function smf_user_model () {origin: model (); $ This- & gt; Smf_db = $ this- & gt; Load-> Database ('smf', TRUE); } Find_all () {$ q = $ this-> Smf_db-> Receive ('member'); Return $ q- & gt; result (); }}  

Controller tester

  expand the class mutipledb controller {function mutipledb () {parent :: controller); $ This- & gt; Load-> Database (); $ This- & gt; Load-> Model ('user_model'); $ This- & gt; Load-> Model ('smf_user_model'); } Function index () {print_r ($ this-> user_model- & gt; find_all ()); Print_r ($ this-> smf_user_model- & gt; find_all ()); }}  

There is some error, the first database uses another database name but it still uses its prefix.

Error

  A database error occurred. Error number: 1146 The table 'smf.rvx_users' does not exist SELECT * FROM (`Rvx_users`)  

If I just load a model ..., it works square extension of the mutipledb controller [mutipledb () {parent: :: controller); $ This- & gt; Load-> Database (); // $ this- & gt; Load-> Model ('user_model'); $ This- & gt; Load-> Model ('smf_user_model'); } Function index () {// print_r ($ this-> user_model- & gt; Find_all ()); Print_r ($ this-> smf_user_model- & gt; find_all ()); }}

Why can this happen? Please help me

I have got the solution.

Set the connection to FALSE for either database configuration or database configuration.

  $ db ['default'] ['pconnect'] = FALSE; $ Db ['smf'] ['pconnect'] = Wrong;  

or

$ db ['default'] ['pconnect'] = TRUE; $ Db ['smf'] ['pconnect'] = Wrong; // and vice versa

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -