Related Tables best practice

I have two (or more) related tables with a many to many relationship. I want to have one form to collect data from the user for these tables, and one page to display the data to the user. My proposed design is as follows:

  1. Generate an active record model for each table using gii.

  2. Write my own model which represents the data as the user will see it, and which will communicate with the active record models.

  3. Use my own model to generate a controller and views using gii.

  4. Edit the controller to get the UserID from the session data and send it to my model, and in turn to the active record models, and then the database.

  5. Edit the views

What are the communities opinions on this approach? Have I correctly understood MVC and the yii framework? Will this work? Is this a good design? And is this best practice?

I think it’s OK.

Probably you could use your "User" AR model for your purpose, but a dedicated model might be cleaner and better. I think you may consider extending it from "User", since it should already have proper relations to the related models.