开发者

CakePHP join Unique constraint for a model

How would I enforce a model constraint for a table users, where not only doe开发者_如何转开发s the username have to be unique for the users table, but also cannot exist in another table? Thanks!


public $validate = array(
    'username' => array(
        'unique' => array(
            'rule' => 'veryUnique',
            ...
        )
    )
);

public function veryUnique($data) {
    return $this->isUnique($data) && $this->OtherModel->isUnique($data);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜