organium
(Organium)
1
Hello. I have two ActiveRecord models Account and Service in relation MANY to MANY. I’d like to add to Account new Service. I wish to do it like this
$account->services[]=$service;//here is the error
$account->save;
But of course it doesn’t works.
Can anyone tell me how to handle it?
dniznick
(Dniznick)
2
Yii doesn’t do this automatically.
You can do this:
foreach($services as $service)
$accountService = new AccountService;
$accountService->field1 = $service->something;
$accountService->field2 = $service->somethingelse;
$accountService->save();
organium
(Organium)
3
So I have to create AccountService model?
It is the only solution?