This commit is contained in:
as2252258@163.com
2021-02-28 01:04:16 +08:00
parent 393c6c8e38
commit 8ef1c9eb66
+17 -1
View File
@@ -580,7 +580,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
foreach ($this->_attributes as $key => $val) { foreach ($this->_attributes as $key => $val) {
$oldValue = $this->_oldAttributes[$key] ?? null; $oldValue = $this->_oldAttributes[$key] ?? null;
if ($val !== $oldValue) { if ($val !== $oldValue) {
$_tmp[$key] = $columns->encode($val, $columns->clean($format[$key])); $_tmp[$key] = $this->toFormat($columns, $format, $key, $val);
} else { } else {
$condition[$key] = $val; $condition[$key] = $val;
} }
@@ -589,6 +589,22 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
} }
/**
* @param $columns
* @param $format
* @param $key
* @param $value
* @return mixed
*/
public function toFormat($columns, $format, $key, $value)
{
if (isset($format[$key])) {
return $columns->encode($value, $columns->clean($format[$key]));
}
return $value;
}
/** /**
* @param $name * @param $name
* @param $value * @param $value