think-orm
think-orm copied to clipboard
比对差异数据有问题
/**
* 获取变化的数据 并排除只读数据
* @access public
* @return array
*/
public function getChangedData()
{
if ($this->force) {
$data = $this->data;
} else {
$data = array_udiff_assoc($this->data, $this->origin, function ($a, $b) {
if ((empty($a) || empty($b)) && $a !== $b) {
return 1;
}
return is_object($a) || $a != $b ? 1 : 0; //这里有个疑问 $a=1 $b='1-11' 也不能正常比较出差异
});
}
if (!empty($this->readonly)) {
// 只读字段不允许更新
foreach ($this->readonly as $key => $field) {
if (isset($data[$field])) {
unset($data[$field]);
}
}
}
return $data;
}