The $wpdb Class — a practical guide to WordPress $wpdb with clear examples you can reuse in real projects.
WordPress Plugin Development Series (28/95). Prefer one article? Read the complete WordPress plugin development tutorial.
Short description
Use `$wpdb->prepare()` for dynamic SQL. Prefer WP APIs when they fit; use `$wpdb` for custom tables/queries.
Prepared query
global $wpdb;
$row = $wpdb->get_row(
$wpdb->prepare("SELECT * FROM {$wpdb->prefix}acme_items WHERE id = %d", $id)
);