How can i check if a specific record exists with Zend_Validate_Db_RecordExists?
Here is my code, i want to match old password before user changes it
$oldpassexist = new Zend_Validate_Db_RecordExists(array(
'table' => 'user',
'field' => 'password',
/** check if password matches
* WHERE user_id = Auth::getuser()->id AND password = md5(THIS FIELD ENTRY)
*/
));
Adding another where clause is pretty easy.
Zend_Validate_Db_RecordExists
allows you to modify theZend_Db_Select
object that it uses internally. So you could write:Which will query both the password as hashed MD5 as well as the user_id field. However, I think this solution is not really elegant. I would probably write my own Validator for this. In any case you should write thorough test cases to detect if the behavior of
Zend_Validate_Db_RecordExists
changes one day.