How to make iteration on wpdb->update or query statement?
How to make iteration on wpdb->update or query statement?
How to make iteration on wpdb->update or query statement?
After instantinating a wpdb the instace vars holding the table names are still not present. You need to call the set_prefix() method, in order to setup all table names according to your other wordpress table prefix. (Very likely this will be wp_ in your case). $newdb = new wpdb( DB_USER , DB_PASSWORD , DB_NAME , … Read more
Ok here’s my altered function but this one doesn’t work at all but maybe you can see wher i go wrong function insertUserShoppingMetaData($params) { global $wpdb; $shopping_meta_table=”wp_shopping_metavalues”; $wp_user_id = $params[‘wp_user_id’]; $checkKeyValues = $wpdb->get_results(“SELECT meta_shopping_key FROM $shopping_meta_table WHERE wp_user_id = ‘$wp_user_id'”); //print_r($checkKeyValues); foreach ($params as $key => $val) { foreach($checkKeyValues as $check){ //UPDATE OR INSERT if … Read more
adding a log row log table, when the draft post publish
I think you have just confused syntax with INSERT 🙂 According to manual the DELETE syntax is: DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [PARTITION (partition_name,…)] [WHERE where_condition] [ORDER BY …] [LIMIT row_count] No VALUES. Rather than forming this query manually you should consider using $wpdb->delete() helper.
$wpdb->get_results in not an array
There is likely no “cp_job” column like you are thinking. extra data/information about a wordpress post type (it looks like ads is a custom post type here) would be stored as post meta in the database. So you might see something in the wp_post_meta table like: meta_id | post_id | meta_key | meta_value XX | … Read more
All you need to do is pass the field you want to order by in your SQL: ORDER BY post_id DESC This example will get the post_ids out with the highest first e.g. 99, 98, 97 OR ORDER BY post_id ASC will do it: 1, 2, 3 and so on. Alternativly if you want to … Read more
Fetching array of postmeta with $wpdb and in_array conditional
WP DB Location for “Next Post to Create” Index Value