CAdvancedARBehavior - adding extra column to MANY_MANY link table


I’m trying to figure out a way to attach an additional “order” value to MANY_MANY relation results. I’ve already done some read&save methods with the use of CAdvancedARBehavior, but this issue gives me headaches.

Lets take a simple glue-table :

fk_table_1 | fk_table_2 | order (int)

What I want to achive is to simply pass a multidimensional array to the model like this:

foreach($arrayFromPostVars  as $order=>$id) {

   $tab[] = array('order' => $order, 'id' => $id);


$model->relatedStuff = $tab;


So, the only thing to tweak is somehow separating the id and order vars and inserting the $order value when the two foreign keys are inserted together into one record.

Some ideas? :)

Thank you in advance!