【发布时间】:2011-12-03 17:51:12
【问题描述】:
我编写了一些验证函数来检查用户的电子邮件是否存在于系统中。
我收到以下错误
注意 (8):未定义的偏移量:0 [CORE/cake/libs/model/model.php,第 1122 行]
这是导致错误的代码
'email' => array(
'emailRule-1' => array(
'rule' => 'email',
'message' => 'email format is incorrect',
'last' => true
),
'emailRule-2' => array(
'rule' => 'checkEmailExist',
'message' => 'email already exists in the system'
)
),
而且 rule2 似乎是造成错误的原因,这里是 rule2:
function checkEmailExist($emailAddress, $user_id){
$this->recursive = -1;
if($user_id > 0){
$user = $this->read(array('email'), $user_id);
if($emailAddress == $user['User']['email'])
return true;
}
$result = $this->find('count', array('conditions' => array('User.email' => $emailAddress)));
return $result > 0 ? false : true;
}
【问题讨论】:
标签: php validation cakephp