mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
修正多对多关联删除
This commit is contained in:
@@ -256,8 +256,7 @@ class BelongsToMany extends Relation
|
||||
$pk = $this->parent->getPk();
|
||||
$pivot[$this->localKey] = $this->parent->$pk;
|
||||
$pivot[$this->foreignKey] = $id;
|
||||
$query = clone $this->parent->db();
|
||||
return $query->table($this->middle)->insert($pivot);
|
||||
return $this->query->table($this->middle)->insert($pivot);
|
||||
} else {
|
||||
throw new Exception('miss relation data');
|
||||
}
|
||||
@@ -288,8 +287,7 @@ class BelongsToMany extends Relation
|
||||
if (isset($id)) {
|
||||
$pivot[$this->foreignKey] = is_array($id) ? ['in', $id] : $id;
|
||||
}
|
||||
$query = clone $this->parent->db();
|
||||
$query->table($this->middle)->where($pivot)->delete();
|
||||
$this->query->table($this->middle)->where($pivot)->delete();
|
||||
|
||||
// 删除关联表数据
|
||||
if (isset($id) && $relationDel) {
|
||||
|
||||
Reference in New Issue
Block a user