WordPress’s WPDB Class

WordPress has a class, $wpdb, that contains several useful functions for manipulating the database. (The $wpdb object is a global variable that WordPress automatically creates.) This is used throughout the core, and by plugin and theme developers to easily run custom MySQL operations. It even has functions for building and executing prepared statements.

You can find a nice introduction and examples at WP Engineer. Here’s a sample of how you would go about changing the title of a post with a certain ID:

$wpdb->update( $wpdb->posts, array( 'post_title' => $new_post_title ),
 array( 'ID' => $the_post_id ) );

That’s just scratching the surface, but it gives a good idea of how the database functions work.

For even more in-depth reading, there’s a good Codex page on the subject as well.