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.
*/
Related Posts:
- Displaying content from one WP site on separate WP site
- Showing content from another wordpress installation database in the page template loop?
- What is the difference between an ORM and an ODM?
- Rename a table in MySQL
- How should I tackle –secure-file-priv in MySQL?
- Checking if Database Table exists
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- Is it possible to define two databases for one installation?
- Connect forms in WP to external database
- Hook into $wpdb
- Syncing local content with development / staging sites
- Export WP database for import using WP-CLI on Vagrant Box
- Is it wise to delete post revisions and autosaves from database?
- Improve or optimize a very slow query
- What is the advantage of separating wp_users and wp_usermeta table?
- “MySQL server has gone away” since update to 3.8
- WordPress page title repeated in SOME pages
- Why is $wpdb->get_results failing on certain tables but not others (which have data)?
- Usage of Direct Database Call Without Caching Error
- How to correctly add a table to the WordPress MySQL database
- MySQL Syntax Error upon restoring database from backup [closed]
- Help running a MySQL query to update all wp_#_options tables in a Multisite install
- Merge two databases: OLD SITE -> NEW SITE
- Is it safe to convert tables from MyISAM to InnoDB?
- Backup another database with BackUpWordPress plugin [closed]
- Easiest Way to Authenticate WP Users Using an External DB?
- Use one WordPress database with multiple instances of one site
- Who is responsible for data sanitization in WordPress development?
- How do I properly update the WordPress database password?
- How to check if a core update, like 4.9.8 → 5.0, involves a database update (migration)?
- $wpdb->insert is not working
- WordPress Install and Database on separate hosting?
- Moving a site from a temporary domain to the live domain [duplicate]
- How do I find out the full path of a page’s template?
- I need to get an array from the wordpress database
- Moving minor updates between local and live sites – just database?
- what is the best way to store user created data?
- Using GROUP CONCAT in my-sql query with wp_usermeta table
- “The link you followed has expired” & “Error while saving” messages when adding new post
- input data and output table [closed]
- How to move the WordPress site Layout from test site to Production site?
- Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Retrieve data from the database to table such as comments in the admin control panel
- Need to store custom user information (many-many relationsips), preferably not as user meta
- charset problem with new custom table
- WordPress and user security
- How to share plugin created database tables between two WordPress sites
- Migrate database between 2 different wordpress version
- SSO system between 2 WordPress installs on different servers
- Form that sends data to an admin panel and can export it
- is $wpdb->get_results() safe enough
- Convert user passwords to MD5?
- is wordpress stores Role Id in WP database?
- Why do database examples sometimes finish with an add_option call?
- Does post_meta data need to be unserialzed?
- Can’t update WordFence Options, clear data manually
- How to backup my site and restore my wordpress site
- Is it possible to have more than 1 MySQL database in my WordPress blog?
- How to fetch records from database WordPress
- AJAX wp-mysql running too slow
- Delete/Replace words from X to Y in post content
- How get Data form wordpress database as array not stdclass?
- cannot connect database
- How to create more than one new wpdb object?
- Multiple WordPress sites installs sharing the same database but with different content and domains
- Brandoo WordPress Unable to Update to WordPress 4.2.2
- Connecting to wordpress database in my application [closed]
- Remote database -> massive response time increase?
- Custom Post Type not showing anything added by code anymore?
- Database tables for sports betting integrated in WordPress
- How do I have a user upload a blog post and then retrieve that to display in a card on the site?
- Delete user with only subscriber role
- WordPress keeps redirecting to localhost
- How to rename custom table name programatically in wordpress?
- How to edit custom table data in frontend
- pre_get_posts causings DB error when using ( ‘posts_per_page’, -1)?
- generate PDF from member information
- mysqli_query(): MySQL server has gone away for Curl Request
- Help posting values to DB on submit using $wpdb->query
- WP website showing blank page after moving from subdomain to main domain
- create a table using user meta custom data
- wpdb query to insert images in to post/page gallery
- Creating a database in my plugin not working
- How to create index (sql) to a meta_key?
- WPCLI search and replace in a particlar site dir effect another site-dir
- get_user_meta and umeta_id
- $wpdb not working
- Database error after importing WordPress
- Send data to database after redirect (and popping out of iframe)
- Simple email input store in database
- Pulling values from a sepcific row in table
- import (migration) user database to wp-users
- Create hundreds of users with just ID in phpMyAdmin
- What is best for saving lot of extra detail of user?
- Insert Extra fields added in the front end registration form to DB
- $wpdb->insert not working for last select option
- How to create a table [closed]
- Upload wordpress from localhost to 000webhost
- WP Multisite Users Not Linking
- Query a meta key using an array of values where the database value is a string