You can set up another connection and use that database the same way you would interact with the WP database with $wpdb
.
This example creates an instance in $odb to be used the same as you would use $wpdb
:
global $odb;
$db_user = "Your DB Username";
$db_pass = "Your DB Password";
$db_name = "Your DB Name";
$db_host = "Your DB Hostname";
$odb = connect_to_intermediary_db( $db_user, $db_pass, $db_name, $db_host );
function connect_to_intermediary_db( $db_user, $db_pass, $db_name, $db_host ) {
$db = new wpdb( $db_user, $db_pass, $db_name, $db_host );
return $db;
}
/*
* You can now use $odb the same as you would
* $wpdb, but it is connected to your custom
* database.
*/