Skip to content

Commit cdeab3d

Browse files
committed
改进初始化方法
1 parent 00af62f commit cdeab3d

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/Entity.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,6 @@ protected function initializeData(array | object $data, bool $fromSave = false)
359359
}
360360

361361
$trueName = $this->getRealFieldName($name);
362-
if (!$this->isView() && !$fromSave && $this->getPk() == $trueName) {
363-
// 记录主键值
364-
$this->model()->setKey($val);
365-
}
366-
367362
if ($this->isView() || $this->isVirtual() || in_array($trueName, $fields)) {
368363
// 读取数据后进行类型转换
369364
$value = $this->readTransform($val, $schema[$trueName] ?? 'string');
@@ -382,6 +377,7 @@ protected function initializeData(array | object $data, bool $fromSave = false)
382377
if (!empty($origin) && !$fromSave) {
383378
$this->trigger('AfterRead');
384379
$this->setOption('origin', $origin);
380+
$this->setOption('get', []);
385381
}
386382
}
387383

@@ -1225,7 +1221,6 @@ protected function setData(string $name, $value)
12251221
public function data(array $data)
12261222
{
12271223
$this->initializeData($data);
1228-
$this->setOption('get', []);
12291224
}
12301225

12311226
/**

0 commit comments

Comments
 (0)