改进Route类setRule方法 修正BelongsToMany类的attach方法

This commit is contained in:
thinkphp
2016-12-22 17:55:35 +08:00
parent 6eedbc5a0a
commit 3a78c93d11
2 changed files with 6 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ namespace think\model\relation;
use think\Db;
use think\db\Query;
use think\Exception;
use think\Model;
use think\model\Pivot;
use think\model\Relation;
@@ -269,7 +270,7 @@ class BelongsToMany extends Relation
$pk = $this->parent->getPk();
$pivot[$this->localKey] = $this->parent->$pk;
$pivot[$this->foreignKey] = $id;
return $this->query->table($this->middle)->insert($pivot);
return $this->query->table($this->middle)->insert($pivot, true);
} else {
throw new Exception('miss relation data');
}