Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I make parallel connection to two DBs on a Model? #211

Open
sagark1510 opened this issue Oct 7, 2015 · 1 comment
Open

How can I make parallel connection to two DBs on a Model? #211

sagark1510 opened this issue Oct 7, 2015 · 1 comment

Comments

@sagark1510
Copy link

Hi as per the documnetation $_db_group = 'group_name'; will make this->_db to point on defined db but how can I make a persistant connection to both db and query both of them at a time?

@rscotten
Copy link

The current version of MY_Model is missing this capability despite the documentation claiming it exists.

To fix, add to the VARIABLES section of MY_Model (before the constructor)

protected $_db_group;

Then in the constructor replace

$this->_database = $this->db;

with

$this->_database = empty($this->_db_group) ? $this->db : $this->load->database($this->_db_group, TRUE);

And then initialize$_db_groupin your model that extends MY_Model:

public $_db_group = 'your_database_name';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants