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);
}
精彩评论