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.
Related Posts:
- How to delete all records from or empty a custom database table?
- Is their any way to Extend WPDB class and Overwrite the Default Query Function
- Doubt using $wpbd->get_col for a single column
- Access WordPress database outside of WordPress
- Help With MySQL to WPDB Query Conversion
- Create a table with wordpress plugin boilerplate
- WordPress and a secondary database?
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- WPDB: Update table
- Issue running db create table query from static method
- Always get creating a new table with foreign key
- How to access the WordPress DB from a plugin file
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- $wpdb->delete not working for me
- How to securely controlling data without keeping it in postmeta?
- Write mysql credentials in plugin
- Proper way to trigger a MySQL query via link in a plugin
- get_var result empty for query of custom table in plugin admin
- Is it safe to increase/alter the size of the wp_post.guid column from VARCHAR(255) to VARCHAR(2048)?
- Delete tables from database when deleting plugin
- WordPress sharding: which multi-DB plugin to use?
- Simple form that saves to database
- Using Vagrant for customizable WordPress Multi-sites [closed]
- How do I check what plugins are enabled via the database?
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- How to update widget_text in the wp_options table
- prefix table and plugins
- how to show database content in wordpress post
- What is the easiest way to implement cascading database upgrade for my plugin?
- [Plugin: Posts 2 Posts] How does it work?
- Storing Email Account Passwords for SMTP Mailing for a WordPress Plugin
- Remove obsolete plugins artifacts from database tables
- If I delete plugins via FTP are settings kept in DB?
- What kind of data is that?
- Cannot login to ADMIN even after changing password in phpmyadmin
- Embed a Google Sheet as you view it in a separate tab?
- Where does WordPress store plugin (enabled/disabled) status for multisite?
- Plugin echos text from shortcode function in gutenberg page editor
- How to access data in wordpress database externally using php
- custom user tables supported in SharDB plugin?
- Creating mySQL procedure with $wpdb
- How to check if tables in WordPress still exists after activations
- Prevent duplicate records in plugin table
- Automatic switch to backup database on fail
- WordPress Integration with Google Groups
- WP Query. Is there a maximum size?
- wp_editor content in plugin options page
- Why this function not working for install database on plugin activation
- How Can I Put Meta_Compare in the Database-Query?
- Can I create a table on my DB without creating a plugin?
- WordPress : Explain Plugins & Theme string value in database
- Plugins in WP_Options but not Active
- How to insert multiple postmeta values with one query?
- Gathering and logging data from a plugin: how to do it without race conditions?
- How to pass the API key to the client from the database? [closed]
- dbDelta not adding additional columns in plugin database update
- Updating options into the wp database performance
- Taxonomy Drill-Down / Plugin Help – hierarchical queries within plugin?
- Best practice to limit results in get_row()?
- Ajax save data to database on document ready, no data being saved
- Plugin has added weird data in wp_options, set to autoload
- External wpdb connections in different plugins on single page
- Mowing site to another domain in simplest way
- WordPress plugin: efficient way to store large data
- Is this plugin safe to run?
- Integrating Custom Database with WordPress
- Getting URL GET parameter with Code snippets and storing it in database?
- Same Plugin tables between wordpress installations
- How to fetch WordPress database values in JavaScript widget
- create pages automatically and dynamically in wordPress
- How to insert a value to decimal type field using wpdb->prepare?
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- add_action(‘the_content’, ‘my_plugin_content’) is null
- Using id to show item
- WordPress database problem wp_posts, primary key
- How to allow URL with filename & extension in wordpress?
- Programmatically generate new pages for a site based on page template and content elements accessed via DB
- Remove special characters from filenames
- PHP message: WordPress database error Deadlock found when trying to get lock
- using wordpress login details for other website / application / forum?
- how to create database to use it in wordpress website?
- how can i get records from wp_postmeta table using particular meta_key in database?
- How to create a custom page for unrelated database?
- User content database [closed]
- Having trouble going from Jfiddle to implementing in WordPress :(
- wpdb get_results() returns only 2 rows
- Collaborate on wordpress local website, share files via dropbox?
- How to find an option in the database?
- Is there a plugin that will override the “Error establishing a database connection” message? [closed]
- Get the url of attachments from the post?
- Create New Admin Menu Section – Like how custom post type works, in a way
- Using wp config to connect to a DB from a plugin
- Shortcode returning specific content of a post
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- get_option returning a different value from what’s saved
- How can I delete the options from DB when the plugin is deleted?
- register_activation_hook not working
- Very slow page loads
- Form with response button after on table after submission
- Can’t save formdata in DB