Created
August 1, 2011 16:47
-
-
Save themusicman/1118500 to your computer and use it in GitHub Desktop.
EE2 Usage of Secondary Database Connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->EE = get_instance(); | |
//get entries form main EE db | |
$entries = $this->EE->db->from('channel_titles')->get(); | |
/* | |
Things to note: | |
1. We are using the secondary index we specified in the database.php file | |
2. And we are passing TRUE as the second parameter | |
3. Lastly we are assigning the new database connection to the variable $secondary_db | |
*/ | |
$secondary_db = $this->EE->load->database('secondary', TRUE); | |
//get people from the secondary db | |
$people = $secondary_db->from('people')->get(); | |
//... other cool code .... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment