Creating new table on trigger

Hi guys.
I need to create new table on trigger event. For example if some button is clicked new table has to be created.
Is this possible?

Hi.
Of course it is.

Create regular button which points to controller/action in where you can use the ‘createTable’ command: Command, yii\db\Command | API Documentation for Yii 2.0 | Yii PHP Framework

1 Like

Ok. I got it
But how could I further operate by the model of new created table if I only created table, not it’s model?

I assume you know the table structure because you have just created it. So you can have class for it extended from ‘active record’ and access the table freely. The model you mentioned is the class instance, either new one you will insert into the table or 'select’ed from the table later in application lifetime.

Ok.Thanks for help