We are trying to pull data from a second database into Wordpress. The secondary database is used internally to store data, and Wordpress (also only used internal) is partially used to display some of this data.
I did not find a reliable way to install Wordpress on SQL Server and thus decided to install it separately on MySQL (as intended) and pull in the extra required data from SQL Server. INSERT
and UPDATE
statement are also expected to be needed.
After some research online the 'best' I could find was to integrate a second ezSQL with a connection to the SQL Server.
Can I just use the default ezSQL 'configuration'?
Is this even possible, without resulting in compatible / interference issues?
ezSQL
$db = new ezSQL_sqlsrv($db_user, $db_password, $db_name, $db_host);
$current_time = $db->get_var("SELECT " . $db->sysdate() . " AS 'GetDate()'");
Wordpress
$wpdbtest_maindb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
$current_time = $wpdbtest_maindb->get_results("SELECT " . $db->sysdate());
Thanks.
new wpdb
) I can only connect to a second MySQL database, as far as I now.wpdb
reference,wpdb
is loosely based onezSQL
, so there is no 'native'ezSQL
to worry about. (Even if there was,$mssql_wpdb = new wpdb( ... );
would create a new instance of thewpdb
class, separate from WP's global$wpdb
, so you would be in the clear. (Unless I'm completely misunderstanding PHP classes...)