Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save themusicman/1118500 to your computer and use it in GitHub Desktop.
Save themusicman/1118500 to your computer and use it in GitHub Desktop.
EE2 Usage of Secondary Database Connection
$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