How create validate unique more columns

I would like to create validate unique more columns


id firstname lastname

1 foo foo

2 foo test

3 test test


insert foo , foo result validate duplication

(sorry I am not good englist

use unique validator for that

read here more also there is in wiki article about it

try adding below to model ruels

array('firstname','unique','message'=>'Firstname {value} already in use!'),

this won’t work if not used from CActiveRecord…

for CFormModel it has additional parameters…

best look in wiki, there is very good article with all parameters available for every built in validation

I found link ,I would like result same extentsion , but I would like CActiveRecord , Do this ?

array(‘firstname+lastname’,‘unique’,‘message’=>‘Firstname {value} already in use!’),