Yii의 activerecord-relation-behavior 확장 기능에 문제가 있습니다. , 모델의 행동이 yiiext을 사용Yii ActiveRecord-Relation 모델 저장하지 않음
이 두 모델 사이의 관계는 잘 살고있다 UserPerson
(프로파일의 종류),하지만, 난 여전히 연결할 수 없습니다 User
및 하위 모델 :
$this
에서
내가 실행할 수 있어야, 상기
User
모델을 확장 모델,이 방법으로
RegistrationModel
$person = new \UserPerson();
$person->full_name = $this->name;
$person->birthday = $this->birthday;
$person->gender = $this->gender;
$this->person = $person;
$this->person->save();
호출됩니다 $this->save()
을하지만이 오류 얻을 :
을You can not save a record that has new related records!
많은 변형을 시도했지만 추한 버전 만 사용했습니다. :(
$person->user_id = $this->id;
//..
$person->save();
사람이 문제에 대한 제안이 있습니까
정상 작동하는 방식입니다 .Yii는 자동 저장을 지원하지 않습니다. lated 레코드. 수동으로 저장해야합니다. –
그렇기 때문에 나는 [activerecord-relation-behavior] (https://github.com/yiiext/activerecord-relation-behavior)를 사용하여 이렇게 작업하고 모델 간의 실제 관계를 갖게되었습니다. – seniorpreacher
오, 죄송합니다, 당신이 그 연장을 언급 한 것을 놓쳤습니다. –