how to use complex store procedure to create a new record in AR model

I am a new dev to use yii, and have a question about how to use the store procedue in the model class.

For example, I have a task model class based on the tbl_task table,via gii tool. When trying to create a new task via UI view, I need to create/update other tables, beside the tbl_task, so I write a store procedure that is easy to complete this.

However, I what to fully use the AR OOP model in yii, instead of simply execute the createCommand("call store procedure") in a php function.

I have read the article here: htt://blog.havenisms.com/using-stored-procedures-in-yii

but this article only address the operation to a single table, instead of mutiple tables. I want to keep other models update data at the same time.

I truly can implement the logical of store procedure by operating the table model AR one by one, however, I also want to utilize the advantage of store procedure.

any good suggestion in this case?

I’m not entirely clear on what your question is but have you considered using the beforeSave() and afterSave() hooks?

Or you could use a trigger to call your stored procedure, I know this is not a Yii solution but it might be right for this scenario.