Select Page

Ever see code like this?

function my_special_function()
{
   global $wpdb;
   $wpdb->get_results( "select * from tbl_blah" );
}

There’s a special variable that WordPress sets up called $wpdb.  It is a window into the database – something that a programmer familiar with SQL can use to access the tables in a WordPress database.  You can read more about it here:

http://codex.wordpress.org/Class_Reference/wpdb

It’s odd that the documentation states:

Methods in the wpdb() class should not be called directly.

Yet, the documentation goes on to explain usage on several of the methods.  In fact, it is one of the longer pages within the WordPress documentation.  Heh.