最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Can I use a wpdb object to connect to a non-Wordpress Oracle database

programmeradmin0浏览0评论
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?

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 0
Add a comment  | 

2 Answers 2

Reset to default 0

This 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.

发布评论

评论列表(0)

  1. 暂无评论