In general, I’d recommend to read about $wpdb
in detail in the Codex.
Some notes:
- Never use the default
wp_
prefix. - Never set a hard coded prefix. It will be set during installation and should later be added using
$wpdb->prefix
. But: Prefixes can be changed with the following SQL command.
"RENAME table wp_posts TO {$wpdb->prefix}posts;"
- Normally there’s always a way to get around custom tables. CPTs and Custom Taxonomies are just an example.