This commit is contained in:
尘缘
2016-05-06 17:28:57 +08:00

View File

@@ -14,6 +14,7 @@ namespace think\model;
use think\Db; use think\Db;
use think\Exception; use think\Exception;
use think\Loader; use think\Loader;
use think\Model;
use think\model\Pivot; use think\model\Pivot;
class Relation class Relation
@@ -453,6 +454,9 @@ class Relation
*/ */
public function save($data, array $pivot = []) public function save($data, array $pivot = [])
{ {
if ($data instanceof Model) {
$data = $data->toArray();
}
// 判断关联类型 // 判断关联类型
switch ($this->type) { switch ($this->type) {
case self::HAS_ONE: case self::HAS_ONE: