creating/adding relationships

I have a many to many relationship and am wondering how I add new relationships. I've read quite a bit about how to query them but cannot find any help on how you add to the relationships, ie: these are Product and Member objects and Members can buy products. How do you add the new relationship.

Is it as simple as just adding an entry to the intermediate array with the two keys or is there a better way.

Also, when have a Product instance, how can I find out if there is a related Member. Do I have to search the $product->BoughtBy array (this works but seems to be a clumsy way of doing it).

The first model class, Member, has the following relationship array:

The other model class, Product, has this relationship array:

and the relationship class has this relationship array:

Yii doesn't support automatically insertion of related objects (and rows in join table).

Quote

Yii doesn't support automatically insertion of related objects (and rows in join table).

Thanks, so I just do it explicitly, thats OK.

What about the query?

Quote

Also, when have a Product instance, how can I find out if there is a related Member. Do I have to search the $product->BoughtBy array (this works but seems to be a clumsy way of doing it).

Do I just search the array or is there a better way to do that?

thanks for your help.

Post your render statement from the controller. The error is possibly because the view does not know $category.