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_Abstract
you will notice this phpDoc above the constructor:
Provides basic configuration for use with Zend_Validate_Db Validators
Setting $exclude allows a single record to be excluded from matching.
Exclude can either be a String containing a where clause, or an array with field
and value
keys
to define the where clause added to the sql.
A database adapter may optionally be supplied to avoid using the registered default adapter.
The following option keys are supported:
- 'table' => The database table to validate against
- 'schema' => The schema keys
- 'field' => The field to check for a match
- 'exclude' => An optional where clause or field/value pair to exclude from the query
- 'adapter' => An optional database adapter to use
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:
$where = 'user_id != 110 AND email != "email@example.com"';
$where = array('users', 'email', $where);
$element->addValidator('db_NoRecordExists', true, $where)
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_NoRecordExists
in the documentation.