I have a mysql table named users having fields: username, password, email I have controller/action like this 'user/update' for adding new user and 'user/update/id/{user_id}' I have same Zend_Form for both controller. For adding new user, I've checked whether the username already exist or not using below code:
$username->addValidator('Db_NoRecordExists', true, array('table' => 'user', 'field' => 'username'));
This works well when new user is added but when editing the user, even when the user leaves the username field as it is, i get username already exist error. Is their a validation that zend provide similar to Db_NoRecordExists for editing the field. In editing case,i want query like:
SELECT COUNT(*) FROM users WHERE username='$username' AND id!=$update_id
How can i do this?