这是一个经过编辑的表单,我根据应用程序ID获取数据 这正是我正在做的是从数据库中获取旧数据(保存之前)并保存在变量中。
保存后,我将获取在数据库中更新的新数据。
$edit_app_id =$_POST['Application_ID'];
//getting old data based on edit_app_id;
$old_data = $wpdb->get_row("SELECT company,collaborateMS,ARM64_Board,collaboration_Details,special_requirements,Status,Application_Comments FROM wp3_AXC where Application_ID='$edit_app_id' ") ;
print_r($old_data);
$result = $wpdb->update($table_name, $item, array('id' => $item['id']));
if ($result) {
$message = __('Item was successfully updated', 'custom_table_example');
$new_data = $wpdb->get_row("SELECT company,collaborateMS,ARM64_Board,collaboration_Details,special_requirements,Status,Application_Comments FROM wp3_AXC where Application_ID='$edit_app_id' ") ;
print_r($new_data);
//comparing 2 results(old_data vs new_data )
$edit_result=array_diff($old_data,$new_data);
print_r($edit_result);
结果:
$old_data : stdClass Object ( [company] => i [collaborateMS] => Join Estuary Development [ARM64_Board] => 2 [collaboration_Details] => i [special_requirements] => i [Status] => Pending [Application_Comments] => h )
$new_data : stdClass Object ( [company] => j [collaborateMS] => Estuary on new ARM64 Hardware [ARM64_Board] => 0 [collaboration_Details] => j [special_requirements] => j [Status] => Pending [Application_Comments] => j )
我正在上面的结果中提到的输出。
我需要比较两者并获得更改。
我使用过array_diff可以使用它。
任何人都可以帮助我提前谢谢!!!!