如何在yii模型规则中将两个字段定义为唯一

I have a table which combination of its two fields should be unique. I guess something like

array('field1 field2', 'unique'),

in rules() method may works but it seems not! What can I use instead?

Try

array('field1', 'UniqueAttributesValidator', 'with'=>'field2'),

For more information, please visit http://www.yiiframework.com/extension/unique-attributes-validator/