Question: I am using `Zend_Validate_Db_NoRecordExists` detailed in the link below to check if a record exists before inserting it.

I have no issues with the basic code and have got it working fine, what I need to do next is add a WHERE clause to exclude records where the field recordDelete = 1.

[Zebd\_Validate\_Db\_NoRecordExists](http://framework.zend.com/wiki/display/ZFPROP/Zend_Validate_Db_RecordExists+-+Zend_Validate_Db_NoRecordExists+-+Ryan+Mauger)

Here is a snippet of the code where I'm using this:

```
$validator = new Zend_Validate_Db_NoRecordExists($options);
$form->getElement('productSTOCKCODE')->addValidator($validator);

```

Thanks

Answer: 
```
$validate = new Zend_Validate_Db_RecordExists (array (
    'table' => 'orders',
    'field' => 'id',
    'exclude' => 'recordDelete = 1'
));

$result = $validate->isValid ('000489FS1qT81XR4GWuV');

```
You could try creating you're own version of it and set the `$_exclude` member variable.

(Untested)

```
class My_Validate_Db_NoRecordExists 
    extends Zend_Validate_Db_NoRecordExists // notice what were extending here
{
    protected $_exclude = array(
        'field' => 'recordDelete',
        'value' => 1
    );
}

```

OR you could just pass the `$exclude` param along to the constructor wherever you're using it:

```
$options = array(
    'table' => $yourTable, 
    'field' => $yourField, 
    'exclude' => array(           // <- set exclude here
        'field' => 'recordDelete',
        'value' => 1
    )
);
$dbValidator = new Zend_Validate_Db_NoRecordExists($options);

```