WordPress: Connect To Two Databases

Ғылым және технология

#wordpress #wordpresstutorial #webdev #webdevelopment #learning
View on website:
scottsweb.dev/connect-to-two-...
Sometimes you need to connect to two databases in WordPress. Maybe it's a remote database, a slave database, or two instances of WordPress so that you can manipulate data between them.
The first (current, local) database is already available to you in variable $wpdb. You can assign it a variable, if you'd like.
The second database connection can be created using the wpdb class. Simply do:
$db2 = new wpdb('db_user', 'db_user_pass', 'db_name', 'db_host')

Пікірлер

    Келесі