首页 > 代码库 > unique 验证 criteria 使用

unique 验证 criteria 使用

model

array(‘code‘, ‘unique‘, ‘criteria‘ =>array(‘condition‘ =>‘schoolid=:schoolid‘,‘params‘ => array(‘:schoolid‘=> $this->schoolid)))

Controller

$model->schoolid = $this->branchId;
$_POST[‘EClassroom‘][‘schoolid‘] = $this->branchId;
$model->attributes = $_POST[‘EClassroom‘];