showing errors with wpdb update or insert query

800

exit(var_dump( $wpdb->last_query )) prints the last query that is executed by database. This is very useful for developers to verify and troubleshoot errors in your query syntax or data format.

One sample is presented here for you.
if ($wpdb->update(“laundry_item_master”, array(
‘dryclean_normal’ => $dryclean_normal,
‘dryclean_urgent’ => $dryclean_urgent,
‘washing_normal’ => $washing_normal,
‘washing_urgent’ => $washing_urgent,
‘pressing_normal’ => $pressing_normal,
‘pressing_urgent’ => $pressing_urgent,
‘modified_date’ => current_time(‘mysql’, false) ,
‘modified_by’ => $current_user->user_login
) , array(
‘item_id’ => $item_id
)) === FALSE)
{
exit( var_dump( $wpdb->last_query ) );
echo “<br /><br />Error occurred while updating record! Please check your entries and try once again or contact Administrator.”;
}
else
echo “<br /><br />Records are successfully updated.”;



Related Articles & Comments

Thank you for visiting us. To continue receiving updates, please Subscribe to our Social Media Channels.

Google+
FACEBOOK
RSS
YOUTUBE
Menu Title
%d bloggers like this: