yii: how to make a unique rule for two attributes

后端 未结 8 547
一生所求
一生所求 2020-12-29 02:26

I have a table like this: (id, name, version, text). (name, version) is unique key, how can i make a rule to validate this.

8条回答
  •  遥遥无期
    2020-12-29 03:14

    May be you can add this rules onto your code

    return array(
        array('name', 'unique', 'className'=>'MyModel', 'attributeName'=>'myName'),
        array('version', 'unique', 'className'=>'MyModel', 'attributeName'=>'myVersion')
    );
    

提交回复
热议问题