mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
改进Model类save方法写入对主键值的判断
This commit is contained in:
@@ -728,7 +728,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
$result = $this->db()->insert($this->data);
|
||||
|
||||
// 获取自动增长主键
|
||||
if ($result && is_string($pk) && !isset($this->data[$pk])) {
|
||||
if ($result && is_string($pk) && (!isset($this->data[$pk]) || '' == $this->data[$pk])) {
|
||||
$insertId = $this->db()->getLastInsID($sequence);
|
||||
if ($insertId) {
|
||||
$this->data[$pk] = $insertId;
|
||||
|
||||
Reference in New Issue
Block a user