Object Cache – Avoid db queries totally
Object Cache – Avoid db queries totally
Object Cache – Avoid db queries totally
This function was being made by an ajax call. The anchor link that made the call pointed to the same url. I changed the href to # and it now works perfectly.
I couldn’t comment, because i dont have the rep Your code will not update because meta_key field is not in the wp_post table. First, you’ll want to query all posts where the meta_key wpcf-engine-days-to-go = 0 and then iterate through the post ID’s and make your changes to the wp_posts. Un-tested Example: $meta_value = 0; … Read more
Formalizing comment answer here: Based on the code you provided the problem is possibly that you are using literal strings rather than interpolated values in your SQL. There’s a big difference between backticks ` and single-quotes ‘. try this: $retArray = $wpdb->get_row(“SELECT * FROM {$wpdb->prefix}wcpl_user_packages WHERE DATEDIFF(NOW(), package_timestamp) >= package_dduration AND id = {$package->id} AND … Read more
wpdb->update update the entire table instead of one row
You have several things going on there and I may not be able to sort them all out. Unless $wpdb->cf7dbplugin_submits has been added to the $wpdb object your query won’t work. You will need something like {$wpdb->prefix}cf7dbplugin_submits instead but I can’t really guess at the right value. You don’t need to swap in 9999. That … Read more
There isn’t an error. The square brackets are empty– aka “no error”. Put a spurious comma in the SQL and you will see what I mean. But your SQL is wildly complicated for you are doing. That is entirely equivalent to SELECT * FROM $table ORDER BY id DESC LIMIT 1 Though, I notice you … Read more
prepare works a bit differently than escape in that it works on whole strings and manages quoting as well. $pat = “UPDATE {$wpdb->posts} SET %s = %s WHERE ID = %d”; $qry = $wpdb->prepare( $pat, $key, $visibility, $post_id ); $wpdb->query($qry); You do not need to swap in the table name at all, and with prepare … Read more
Nacin summed it up in detail and I’m guessing this is a duplicate (looking in a minute), for now go read this
For Placehold to work, you should use $wpdb->query like: $wpdb->query( $wpdb->prepare( ” SELECT * FROM mailer WHERE id = %d “, $_GET[‘caId’] ) ); However in my opinion, the best option is to simply validate the get-parameter and than use it in $wpdb->get_results , like: $catId = $_GET[‘caId’]; if(is_numeric($catId)){ $_crds = $wpdb->get_results(” SELECT * FROM … Read more