Using wpdb to connect to a separate database

Posted by Prem Tiwari | Updated on

The wpdb object can be used to access any database and query any table. Absolutely no need to be WordPress related, which is very interesting.

The benefit is the ability to use all the wpdb classes and functions like get_results, etc so that there’s no need to re-invent the wheel.

Here’s how:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers