Unique Validation For Composite Keys

Hi all,

back with new question. Here’s my table structure for groupmember table which stores the users who are added in the group with unique role.

groupmember (


GroupId int(10) NOT NULL,–>ref group(ID)

UserId int(10) NOT NULL,–>ref user(ID)

UserRoleId int(10) NOT NULL–>ref userrole(ID)


I alredy used [size="5"]UNIQUE[/size] validator bt it validates each attribute.

The question is that the validation should be unique for all attribute (like composite primary key in database). E.x. values for (groupId,UserId,UerRole) = (1,1,1) IS valid for first time but again we insert it must be deny. also (1,1,2) should also be valid.

Pls help.

Any link forward it

there is a lot about this on forum and in extensions library… try: http://www.yiiframework.com/extension/unique-multiple-columns-validate/