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)?
- $wpdb->replace: WHERE?
- How do I network enable a plugin for a multisite install via the database?
- WordPress Backend HA (Automatic failover)
- import posts with dutch/special letters
- Automatic switch to backup database on fail
- $wpdb->get_row returns column name instead of column value
- How can I change the meta_key for a particular piece of information?
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- WordPress Integration with Google Groups
- WP Query. Is there a maximum size?
- wp_editor content in plugin options page
- Multiple instance of data in plugin custom database table on plugin activation
- WordPress plugin creating database in localhost but not on real host
- Why this function not working for install database on plugin activation
- How Can I Put Meta_Compare in the Database-Query?
- “Master” WordPress Multisite – Database Sync
- Better ads plugin has 500.000 entries in wp_postmeta
- Object method calling for global $wpdb in header.php
- WooCommerce search products between price range using WP_Query
- Using wpdb without loading all plug-ins via wp-load.php
- How to create multiple database tables on plugin activation?
- Can I create a table on my DB without creating a plugin?
- WordPress : Explain Plugins & Theme string value in database
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- Does deleting a Plugin via the WordPress admin ‘completely’ remove the code?
- Creating a CSV with PHP inside the plugin directory
- Plugins in WP_Options but not Active
- How to insert multiple postmeta values with one query?
- How do i edit the plugin files in DataBase via phpMyAdmin?
- WordPress as a data-store?
- How to insert and call new data in wordpress website database through a plugin
- Cannot get wpdb data (Error in a simple fuction) [closed]
- 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]
- correct validate and sql query
- correct sql query
- SQL query, error
- Problem of encoding characters (apostrophes) in my posts publications
- Separate database for a wordpress plugin
- Is there a rule for wordpress plugins developers to not do any database changes upon update?
- How to keep variable `$post` to using in another file
- dbDelta not adding additional columns in plugin database update
- $wpdb update query in plugin only updating one column
- Create a post builder skin in a plugin
- $wpdb->query can’t insert data
- Custom WordPress Table wpdb
- Updating options into the wp database performance
- Taxonomy Drill-Down / Plugin Help – hierarchical queries within plugin?
- Best practice to limit results in get_row()?
- How to customize a title by passing query string?
- Making my plugin create a page?
- Ajax save data to database on document ready, no data being saved
- Add some fileds to the wp_posts table
- How to edit a published post?
- Best/Correct way to add an option to a category
- What is the best way to cache pages on WordPress
- Plugin has added weird data in wp_options, set to autoload
- How to do database for download stats?
- What is the WordPress approach to custom data?
- How to create plugin/ page that reads from database
- How retreive saved data from gravity forms in my template?
- problem with sql query
- add_query_arg not work in admin
- Connecting to a different database
- DB Query not working in Plugin
- Assign all Post in Wp to a specific Category
- Query Column of Specific ID from Database Table
- External wpdb connections in different plugins on single page
- Storing The Data Collected by Ninja Forms into Another (custom) Database [closed]
- How to return the values from a row where a value occurs for the first time among the rows available?
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- Where do plugin variables live in the db?
- WordPress plugin boilerplate table create
- How to use apply_filters?
- Mowing site to another domain in simplest way
- Store plugin page content in wp_options?
- How to relate 3 wordpress components with each other (Create database relationships)
- Creating a search form and displaying results
- WordPress plugin: efficient way to store large data
- Displaying data from another database
- How can I store data from custom fields to custom tables?