XOR functionality for meta_query

Okay! So, having spent all the night in order to find a right solution… finally.. I did it. Here is the right method, that works in my situation. The $wpbd method is pretty cool and complicated at the same time. While using this method do not forget to cache queries properly with php-apc or memcache. … Read more

Exclude subscriber users from user list

This new method should work. It looks at all the capability values to find “subscriber”, and hides it. Try this query $wpdb->get_results( “SELECT display_name FROM $wpdb->users WHERE 1=1 AND {$wpdb->users}.ID IN ( SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta WHERE {$wpdb->usermeta}.meta_key = ‘{$wpdb->prefix}capabilities’ AND {$wpdb->usermeta}.meta_value NOT LIKE ‘%subscriber%’) ORDER BY display_name ASC” );

Converting mysql to $wpdb

You can query INFORMATION_SCHEMA and achieve the same: function getEnumValues($table, $field) { global $wpdb; $result = $wpdb->get_row(“SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ‘” . DB_NAME . “‘ AND TABLE_NAME = ‘” . $table . “‘ AND COLUMN_NAME LIKE ‘” . $field . “‘”); if($result === FALSE) { die($wpdb->last_error); } // this is the column … Read more

How to save html and text in the database?

Just use the wpdb insert and update API, no escaping or sanitizing needed as per the doc, just the raw data. Data: (array) Data to replace (in column => value pairs). Both $data columns and $data values should be “raw” (neither should be SQL escaped). Something like: $wpdb->insert( $wpdb->prefix . “myTable”, array( “doiBody” => $_POST[‘doi-body’] … Read more

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

The difference is what is returned. The WPDB query() method returns true for CREATE, ALTER, TRUNCATE and DROP queries, an integer of how many results for all other queries, or simply false if if there’s an error. The WPDB get_results() method actually returns the entire result of the query (like you would get running the … Read more

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