MANY TO MANY

Hi,

I have this table that I am using to create MANY TO MANY relationships between a certain set of tables in my application.




create table ComponentIntegration

(

	id int auto_increment primary key,

	id_one int not null,

	model_name_one tinyint(1) not null,

	id_two int not null,

	model_name_two tinyint(1) not null,

	fk_id_with_user_id int not null

);



id_one and id_two are the ids of the models I want to integrate.

model_name_one and model_name_two are references to the model names of the ids, this is represented as a number however it could have been represented as a varchar i.e. users, comments. Linking the users and comments table together via their ids.

How can I create a MANY TO MANY relationship in Yii using this table structure. For instance this would link both user record with comment record …

id_one = 5

model_name_one = "User"

id_two = 14

model_name_two = "Comment"

Links user 5 with comment 14.

You can add extra conditions when describing HAS_MANY. I think that on parameter is the right one.