I simply have a quick question. I've found information related to this, but I'm not completely sure if this is possible. I know that I can create a second database connection using the wpdb object as follows:
$new_db = new wpdb(usr, pw, name, host);
However, is this compatible with an Oracle database that wouldn't have any of the Wordpress tables?
This question already has answers here: Connecting to external oracle database (2 answers) Closed 5 years ago.I simply have a quick question. I've found information related to this, but I'm not completely sure if this is possible. I know that I can create a second database connection using the wpdb object as follows:
$new_db = new wpdb(usr, pw, name, host);
However, is this compatible with an Oracle database that wouldn't have any of the Wordpress tables?
Share Improve this question asked Jun 11, 2019 at 19:07 EliEli 691 gold badge2 silver badges10 bronze badges 02 Answers
Reset to default 0This should be possible. You can try
function seconddb() {
global $seconddb;
$seconddb = new wpdb('Username','password','database name','localhost')
}
add_action('init','seconddb');
in your functions.php.
Then you can fire a query to the new db like $seconddb->get_row( "SELECT * FROM yourtable..." );
instead of $wpdb->get_row()
.
Although this got asked some time ago, it came time to actually implement this and ran into issues (see: Connecting to external oracle database)
The answer is no. Oracle is not a mysql based database, thus wordpress will not be able to connect to it via wpdb.
For more information see the linked post.