Welcome Guest, Not a member yet? Register   Sign In
Switch Database

I think one of them could suite you when loading a model (from docs):
Use this in Controller.
PHP Code:
$db_config_file $this->config->load('database');
$config $this->config->item('default''database');

// Load model with DB1

// Load model with DB2
$config['database'] = 'DB2';

// Load model with DB3
$config['database'] = 'DB3';

There're more advanced ways. In CI3, you have plenty of other options. But you will need to try coding it in first to see how things work.

You can also load database configuration using config library, then load them into models.

I can't guess what will suite you, but you need to see what's on the table and decide what you want to use and make your own approach. 

Various ways of loading configuration and database connections was especially made for you with dozens of ways to integrate your logic.

Controllers and Models are extensible, and could allow you to prepare connection before you load controllers or classes.

Messages In This Thread
Switch Database - by federcla - 04-13-2020, 10:44 AM
RE: Switch Database - by cyberstunts - 04-13-2020, 05:04 PM
RE: Switch Database - by federcla - 04-14-2020, 03:43 AM
RE: Switch Database - by cyberstunts - 04-14-2020, 05:41 AM

Theme © iAndrew 2016 - Forum software by © MyBB