I have read here about switching the current wp database on the fly using
$wpdb->select('database_name');
Once done, I understand that i will have to issue the same statement to the original database.
Questions:
-
Right after changing the database, do i need to flush caches or similar stuff to get things working properly? Will I need to call again WP header?
-
Potential issues?
Yes it works!
This is the code, assuming both the databases share the same username & password:
Once done, re-issue the same statements, with the original database name.
Can’t see any performance issue at the moment, maybe because this is done when building a custom form picking data from two posts out of two databases.
It may impact performance when used on a large amount of rows in batch loop…