mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
修正Model类的save方法
This commit is contained in:
@@ -995,7 +995,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 模型更新
|
// 模型更新
|
||||||
$result = $this->db()->where($where)->update($data);
|
$result = $this->getQuery()->where($where)->update($data);
|
||||||
|
|
||||||
// 关联更新
|
// 关联更新
|
||||||
if (isset($relation)) {
|
if (isset($relation)) {
|
||||||
@@ -1022,11 +1022,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->db()->insert($this->data);
|
$result = $this->getQuery()->insert($this->data);
|
||||||
|
|
||||||
// 获取自动增长主键
|
// 获取自动增长主键
|
||||||
if ($result && is_string($pk) && (!isset($this->data[$pk]) || '' == $this->data[$pk])) {
|
if ($result && is_string($pk) && (!isset($this->data[$pk]) || '' == $this->data[$pk])) {
|
||||||
$insertId = $this->db()->getLastInsID($sequence);
|
$insertId = $this->getQuery()->getLastInsID($sequence);
|
||||||
if ($insertId) {
|
if ($insertId) {
|
||||||
$this->data[$pk] = $insertId;
|
$this->data[$pk] = $insertId;
|
||||||
}
|
}
|
||||||
@@ -1114,7 +1114,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
$db = $this->db();
|
$db = $this->getQuery();
|
||||||
$db->startTrans();
|
$db->startTrans();
|
||||||
try {
|
try {
|
||||||
$pk = $this->getPk();
|
$pk = $this->getPk();
|
||||||
@@ -1228,7 +1228,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除当前模型数据
|
// 删除当前模型数据
|
||||||
$result = $this->db()->where($where)->delete();
|
$result = $this->getQuery()->where($where)->delete();
|
||||||
|
|
||||||
// 关联删除
|
// 关联删除
|
||||||
if (!empty($this->relationWrite)) {
|
if (!empty($this->relationWrite)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user