Unique username with a twist


I have the following Model/Table setup


+ USER      +


+ id        +

+ domainID  +

+ name      +


I would like to tell my Model that the [i`]Name[/i] column needs to be unique combined with [i]domainID[/i] (so I can actually have the same name, as long as thedomainID` is different)

Is there an easy way of doing this? (i just can’t find it)

Or I have to create a custom validation rule for this?



So I’m trying to create a new validator rule and this is what I got

class uniqueindomainValidator extends CValidator



    protected function validateAttribute($model,$attribute) {

       die( 'testing' );


and the error:

Fatal error: Cannot redeclare class uniqueindomainValidator ...

has anybody seen this before?



Check the unique-multiple-columns-validate Extension

thanks Tydeas - I ended up using it. (now we know that it works on Yii 1.1.2 :) )