改进聚合模型 主表的主键名和附表的关联键名一致导致关联数据写入错误的问题

This commit is contained in:
thinkphp
2016-09-29 21:11:35 +08:00
parent 5098d53ea9
commit 62cd93f1fe

View File

@@ -245,7 +245,7 @@ class Merge extends Model
// 写入附表数据
$source = $this->data;
if ($insertId && is_string($pk) && isset($source[$pk])) {
if ($insertId && is_string($pk) && isset($source[$pk]) && $this->fk != $pk) {
unset($source[$pk]);
}
foreach (static::$relationModel as $key => $model) {