CodeIgniter Multiple database use without changing existing code for first database -


i have configured second database codeigniter , able create table. problem every existing lines of code using $this->db uses second database naturally pops error. let me explain bit more details:

i use migration library of codeigniter , in new migration, create database dbforge $this->dbforge->create_database('website_store'). far good, connect database using $db2 = $this->load->database('store', true); , create table. here well.

then migration ends , codeigniter tries update migration table push latest version, looks store database instead of default database, pops error:

table 'website_store.migrations' doesn't exist update `migrations` set `version` = 45 

hopefully knows using multiple database , migration library. way, in database.php file, set use default database: $active_group = "default";, not store database should work. looks migration library sees there database loaded, feels lazy , uses 1 instead.

note: looks these guys had similar problems fixed setting 'pconnect' 'false', nice keep connection both database:

convenient way load multiple databases in code igniter

error using multiple database in codeigniter

in ci have dealt multiple databases using:

function readfromotherdb(){     $config = array(         'hostname' => "xxx",         'username' => "xxx",         'password' => "xxx",         'database' => "xxx",         'dbdriver' => "mysql",         'dbprefix' => "",         'pconnect' => false,         'db_debug' => true,         'cache_on' => false,         'cachedir' => "",         'char_set' => "utf8",         'dbcollat' => "utf8_general_ci"     );      $otherdb = $this->ci->load->database($config, true);      $query = $otherdb->get_where('users', array('email' => $_email));      $otherdb->close(); } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -