I am creating a plugin for WordPress, and part of the plugin requires me to connect to an external WordPress site and use this external database to get some information. I made a connection and I accessed an external database $wpdb
using the following code:
global $new_wpdb;
define( 'BLOCK_LOAD', true );
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/wp-db.php' );
$new_wpdb = new wpdb( $username, $password, $dbname, $servername);
$new_wpdb->show_errors();
When I use print_r($new_wpdb);
, I get an array, and I can see the values for username, password, etc., but there is no value for prefix
or base_prefix
. It simply displays the following for the prefix:
[prefix] => [base_prefix] =>
How to get the prefix used by an external database?
source
share