I use the transactional in ActiveReord, the code is :
public function transactions()
{
return [
'CreateOrUpdate' => self::OP_INSERT | self::OP_UPDATE,//I set the Scenario to `CreateOrUpdate`
];
}
Note,I just set the Scenario in transations but not set in rules,then i save the model :
$model = $this->findModel($id);
$model->oldAssociateModules = $model->associateModules;
$model->setScenario('CreateOrUpdate');
but there is an error throw :
Invalid Parameter – yii\base\InvalidParamException
Unknown scenario: CreateOrUpdate
I think the error is cause of I am not set the scenario named CreateOrUpdate in rules. but i am just want to set the scenario in transactions() , who can help me??