Database with Junction Table

Dear all

Somehting is not clear to me. When having two tables (e.g. Table Customer and a Table Contact) where the relation between Customer and Contact is modelled via a junction table Customer_has_Contact, what is the best way to work with these. The guide2.0 states that the following statements would be enough:


$customer = new Customer();

$contact = new Contact();


$customer->save();

$contact->save();


$customer->link('contactId',$contact);

Although this does not seem to work, which seems normal to me as how can Yii know that the junction table is Customer_has_contact. If eg. Customer_hates_Contact would exists, how could it differentiate between those relations?

So my question: how do we need to work efficiently with the link method?

Kind regards

Jens Buysse