mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 16:12:49 +08:00
改进model类的save方法的复合主键包含自增的情况
This commit is contained in:
@@ -1123,12 +1123,14 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取自动增长主键
|
// 获取自动增长主键
|
||||||
if ($result && is_string($pk) && (!isset($this->data[$pk]) || '' == $this->data[$pk])) {
|
if ($result && $insertId = $this->getQuery()->getLastInsID($sequence)) {
|
||||||
$insertId = $this->getQuery()->getLastInsID($sequence);
|
$pks = (array) $pk;
|
||||||
if ($insertId) {
|
foreach ($pks as $pk) {
|
||||||
|
if (!isset($this->data[$pk]) || '' == $this->data[$pk]) {
|
||||||
$this->data[$pk] = $insertId;
|
$this->data[$pk] = $insertId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 关联写入
|
// 关联写入
|
||||||
if (isset($relation)) {
|
if (isset($relation)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user