WP_USE_EXT_MYSQL

This constant is actually never defined in core code at all. You can define it yourself in wp-config.php configuration if you need to, but core doesn’t need it defined for normal operation. It only exists for re–configuring into running untypical setup.

Get data from database using $WPDB

It may be because group doesn’t exist in the postmeta table. Your meta_key is probably called group and has a meta_value of bicyclegroup. This is assuming you haven’t modified the postmeta table. What you could try is: $sql = “SELECT * FROM $wpdb->postmeta WHERE meta_key = ‘group’ AND meta_value=”$group””; This will return: meta_id post_id meta_key … Read more

How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?

I would use a custom query like this: $amsterdamstore_args = array( ‘post_type’ => ‘store’, // This is your custom post type ‘tax_query’ => array( array( ‘taxonomy’ => ‘city’, // This is your custom taxonomy ‘terms’ => ‘Amsterdam’, // The term you search for ‘field’ => ‘name’, // Check against the term’s name (you might use … Read more

How would I format a query that depends on post parent taxonomy

You can still use get_posts: $parents = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘my_custom_post_type’, ‘fields’ => ‘ids’, // Just get IDs, not objects ‘tax_query’ => array( array( ‘taxonomy’ => ‘my_custom_tax’, ‘field’ => ‘slug’, ‘terms’ => array( ‘foo’, ‘bar’, ), ), ), ) ); $post_ids = get_posts( array( ‘posts_per_page’ => -1, ‘post_parent__in’ => $parents, ‘post_type’ … Read more

Check if row exists before inserting

There are several problems with your function. For example, $tablename points to a table that does not exist. And you don’t need it anyway. If you are trying to create a new user if that email does not exist then try this: function register_user() { global $wpdb; $name = $_POST[‘name’]; $email = $_POST[’email’]; $password = … Read more

How to fetch an array in $wpdb?

You have a problem with your query which is you can’t use GROUP BY and ORDER BY before WHERE replace FROM tablename GROUP BY submit_time ORDER BY submit_time DESC with FROM tablename This is your query $results = $wpdb->get_results( ‘SELECT DATE_FORMAT(FROM_UNIXTIME(submit_time), “%b %e, %Y %l:%i %p”) AS Submitted, MAX(IF(field_name=”Name”, field_value, NULL )) AS “Name”, MAX(IF(field_name=”Email”, … Read more

Create an array with a string key from wpdb->get_results

Found the solution: $currentProducts = $wpdb->get_results(“SELECT feedid, id, size, price FROM products WHERE shopid = $shopid”, OBJECT_K); The OBJECT_K parameter makes an associative array with feedid as key: https://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results

wpdb::prepare() isn’t working

The issue is that in My/SQL table names are not strings. So ‘wp_product_codes’ is being interpreted as a string instead of as an actual table. This is why you usually don’t see tables passed into wpdb::prepare() – you should know the table names as they won’t change where wpdb::prepare() is meant for data that you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)