My code is
if( $wpdb->update($tableName,array('opt_value'=>$cInfo),array('opt_name'=>'showWeatherWidget')))
//show success message
else
// show failure message
This is not correct, $wpdb->update()
returns false if it doesn’t change any data, but there were no errors. Can someone tell me the proper way to display a success message that a field was updated?
1
The correct way is with === FALSE
which differentiates from equalling zero, which is what a succesful query with no results returns.
if( $wpdb->update($tableName,array('opt_value'=>$cInfo),array('opt_name'=>'showWeatherWidget')) === FALSE)
//show failure message
else
// show success message