In my knowledge, I have done everything correctly. I can confirm that the table name is correct(aupair_registered_employee_prefferred_countries), ID is correct. I dont understand why it fails. Also, the "last_error and "last_query" are no help. it cant detect the error. At this point I dont know how to move forward with this.
function update_employee($request){
global $wpdb;
$data = array(
'wp_user_id' => 70,
'country' => 'Sloveniax',
'is_activated' => 1,
'year_created' => 2020,
);
$where = array('ID' => 27);
$result = $wpdb->update('aupair_registered_employee_prefferred_countries', $data, $data_where);
if($result){
wp_send_json_success("SUCCESS : ".$wpdb->last_error);
} else {
wp_send_json_error("ERROR21 : ".$wpdb->last_error." RESULT ".$result);
}
die();
}
//aupair_registered_employee_prefferred_countries
Can anyone shed some light on me on this one!!!!
2
Answers
I used "$data_where" instead of just "$where". Also, if somebody has this issue make sure that before updating, you have udpated any value. Wordpress update wont trigger unless there is any value that is updated.
You should pass
$wpdb->prefix
to table name.