Creating Different Inserts On The Same View

Hi, this is my first post in the forums and also my first time working with the Yii Framework. Although I have already read the Agile Web development book I’m still getting a grasp on how Yii works. Currently I’m developing a system in which I have to make different inserts to different models on the same view. I have attached the ER diagram of the tables that I’m working on. There are three catalog tables with predefined information: zona, área y especialidad (Zone, area and specialty in English). The other three tables are the ones that I want to populate “zona_proyecto”, “area_zona”, “especialidad_area_zona”. Each project has zones and each zone has areas and each area has specialties. I want to create a form with dropdowns to choose the zone the area and the specialty and save that information into the three relational tables.

The question is, how do I create the view and how do I create the functionality to make the insert first on the first table, then on the second and then on the third?(to not violate the foreign key constraints) I have already created a model and controller for each table that I want to populate.

Thaks in advance.

Hi,

if you want to insert multiple table…

try this code…it’s just sample

First you can insert the area table


$model= new Area();

$model->setAttribute();

$model->save(false);

then after if you want to insert the area_id on area_zona table…

try this code…




$area_zona= new AreaZona();

$area_zona->area_id=$model->id

$area_zona->save(false);

hope you can understand my code. :rolleyes: