I want to add check for more than one values in where clause. Db_RecordExists just check for one filed. I have read that you can extend zend validate abstract class and you can have your own validator. can I have one little example about this please.
Thank you…
What are you trying to do exactly? To me, you don’t even need a custom validator.
If you read carefully the source code of
Zend_Validate_Db_Abstractyou will notice this phpDoc above the constructor:Which means that if you want to check if a record exists using more than one value, you can do it simply in passing the where clause to the validator instead of a pair field/value:
This will basically check if a record exists in the users table, and exclude rows where user id != 110 or email@example.com. Naturally, I recommend you to use Zend_Db methods such as
quoteIdentifier()in order to generate a fully escaped query expression.You can add as many fields as you want of course.
You can find more information about
Db_NoRecordExistsin the documentation.