在我的控制器中,我有
if(isset($username) && trim($username)!=='')
{
$exist = $user_obj->checkUsernameExist($username);
if($exist == '1')
{
$form->getElement('username')->addError('This username exists.');
}
}
if ($form->isValid($_POST) ) {
$user_obj->insertUser($_POST);
$this->_helper->flashMessenger->addMessage('User Added Successfully.');
$this->_redirect('/users/usersadministration/');
exit();
}else { //echo 'failure';
//print_r($form->getErrors());
}
但即使$exist
值为1