Database Structure on Different Servers

I don’t think WordPress can manage two databases at the same time (unless you tweak it significantly, by means of HyperDB1). So, you’d probably will like the job of abstracting two databases and making them look like one to WordPress to be done by the database functionality. WordPress can work mostly with MySQL (see WordPress … Read more

SQL syntax error when getting data for a url

Are you sure you didn’t mean $wpdb->staff? By ommitting the $, the query now looks for a table called wpdb->staff, which isn’t valid SQL As an aside, had you considered using a custom post type/user meta instead of a custom table? Or even a custom taxonomy on users? Note as well that if you never … Read more

Update MySQL query so that it functions again

mysql_fetch_object() was deprecated in PHP 5.5 and fully removed in PHP 7.0, which is probably why it no longer works for you. It’s always better to use WP functions – often they are wrappers for something in PHP (or elsewhere), but by using the WP wrapper version, it usually protects you from deprecation (since the … Read more

Is it possible to create a WordPress table using array and loop?

This is a code review question more than a WordPress question. Please post these in the Code Review Stack Exchange in the future. You have a couple things wrong or not according to best practices. Comments inline for where I made changes. $cr_table_array = array( array( ‘data_field’ => ‘id’, // Add primary key here to … Read more

WordPress plugins for database queries

I don’t know of a plugin that allows you to do this out of the box, but as you are (/seem to be) comfortable with database manipulation, I’ve outlined below how you can achieve what you want using custom coding. You can run custom queries using the wpdb-class. There are a few posts on WPSE/SO … Read more

Are these WordPress tables safe to add indexes to?

These tables aren’t indexed These tables are indexed For example, the post meta table has these indexes: https://codex.wordpress.org/Database_Description#Indexes_5 You’re more likely to cause issues or reduce performance through bad indexing by adding new indexes. WP already specifies indexes for tables “dbmain” “wp_mf_post_meta” “post_id” “Not indexed” “dbmain” “wp_mf_custom_fields” “custom_group_id” “Not indexed” Those are not WordPress tables, … Read more

WordPress(wpdb class) and mysql stored procedures

wpdb detects the type of query and returns the result if it starts with select, else the affected rows. Since yours starts by call, it’s probably mistaking it for an insert, update, delete, etc. statement. Try this (might trick wpdb into thinking it’s a select statement: /* select */ call …; Or this (not sure … Read more

Problem with admin login after deployment

I suspect either the culprit is one of the plugins or the theme you are using. so, try: -deactivating ALL plugins temporarily to narrow down the problem. If the problem goes away, activate them individually (one-by-one) to find the problematic plugin. If you don’t have access to your admin area, try deactivating plugins manually via … Read more

SQL Query in WordPress – Getting Impossible WHERE error

Look at your conditions: WHERE ( ( (meta_key=’user_school_subjects’ AND meta_value LIKE ‘%history%’) OR (meta_key=’user_professional_courses’ AND meta_value LIKE ‘%history%’) OR (meta_key=’user_language_tutoring’ AND meta_value LIKE ‘%history%’) OR (meta_key=’user_music_tutoring’ AND meta_value LIKE ‘%history%’) ) AND (meta_key=’user_gender’ AND meta_value=”male”)) There is no way that you can have a meta key matching one of these– user_school_subjects, user_professional_courses, user_language_tutoring, user_music_tutoring … … Read more