Articles of database

WPDB – Read and write value from / to database

I have a custom field in usermeta called vatnumber. If the field has a value, how do I read that specific value for user X? Here’s what I have so far: <tr class=”vatnumber”> <th><?php _e( ‘VAT-Number:’, ‘wpdb_usermeta’ ); ?></th> <td><?php $wpdb->get_results(“SELECT userid, vatnumber FROM usermeta”); ?></td> </tr> But I don’t quite understand wpdb yet. I […]

Why user_pass column in wp_users table is varchar(64)

while working on a project, I found that “user_pass” column in “wp_users” table is varchar(64). WordPress always stores user password in md5 which is a 32 char ASCII string. So why not store it in char(32) with ascii collation. I am asking because I am working on a table that stores user password. Is there […]

Error establishing a database connection on Installation

I was working on my MacOS System with everything well configured and working. Now I try to migrate all of my work to Windows using the same software as in MacOS MAMP to run WordPress on localhost. So I set up MAMP on my Windows System and copied all files from GitHub to my workstation […]

Restore woocommerce orders

Recently my server team replaced my database and they put our previous Database . So we lost our order details of one day[particular day] . Now the server team give the backup that contain the lost day order details . Now please tell how can i restore these orders ? I cannot replace our database […]

Why my wp_posts data is so huge?

My WordPress has only 23 posts but the wp_posts data is over 70MiB. Is it the average size? The Posts I have were created with WPBakery Visual Composer and has 10 revisions. However, I deleted all the revisions with Revision Control but the wp_posts data size has no change. — update info on Apr 22, […]

SQL Error wp_commentmeta – incorrect table definition

I’m trying to import a database and wonder how I can stop getting the following error? “#1075 – Incorrect table definition; there can be only one auto column and it must be defined as a key “ Here’s the result when importing using PHPMyAdmin. SQL query: — — Database: `db_factorypattern` — — ——————————————————– — — […]

multiple wordpress installation with shared usertable on an different database

I have multiple wordpress installation, and I would like them to share the same usertable. The wordpress installations are already up and running, and they all have their own database. Is it possible to somehow define the users database too and not only the table in the database? define( ‘CUSTOM_USER_TABLE’, $table_prefix.’my_users’ ); define( ‘CUSTOM_USER_META_TABLE’, $table_prefix.’my_usermeta’ […]

wpdb query on custom table not working

I want to show one custom table from my database on which WordPress is installed. So I googled this code: <?php $results = $wpdb->get_results( $wpdb->prepare(“SELECT * FROM sparte-bogensport”) ); foreach ($results as $result) { echo ‘<p>’ .$result->id. ‘</p>’; } ?> But it does not work. When I changed the table name to one word for […]

dbDelta() Error – Incorrect index name '' for query ALTER TABLE

The famous dbDelta() function in WordPress is causing me problems in multiple plugins. No change I make to my create table query seems to fix the problem or it does fix it and dbDelta() causes a different error after the change. Advice on these specific CREATE TABLE queries would be appreciated a lot. [21-Oct-2016 23:01:29 […]

Get posts and include taxonomy term

How can I return taxonomy terms within post data, from the same query. Currently I’m calling get_posts / wp_query and then looping over and calling wp_get_post_terms. Needless to say it thrashes the database and results in far too many queries. For context, I’m listing all WooCommerce products (‘product’ post type) and then adding in ‘designer’ […]