Zend Framework  1.12
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_Validate_Db_Abstract Class Reference

Public Member Functions

 __construct ($options)
 Provides basic configuration for use with Zend_Validate_Db Validators Setting $exclude allows a single record to be excluded from matching.
 
 getAdapter ()
 Returns the set adapter.
 
 setAdapter ($adapter)
 Sets a new database adapter.
 
 getExclude ()
 Returns the set exclude clause.
 
 setExclude ($exclude)
 Sets a new exclude clause.
 
 getField ()
 Returns the set field.
 
 setField ($field)
 Sets a new field.
 
 getTable ()
 Returns the set table.
 
 setTable ($table)
 Sets a new table.
 
 getSchema ()
 Returns the set schema.
 
 setSchema ($schema)
 Sets a new schema.
 
 setSelect ($select)
 Sets the select object to be used by the validator.
 
 getSelect ()
 Gets the select object to be used by the validator.
 
- Public Member Functions inherited from Zend_Validate_Abstract
 getMessages ()
 Returns array of validation failure messages.
 
 getMessageVariables ()
 Returns an array of the names of variables that are used in constructing validation failure messages.
 
 getMessageTemplates ()
 Returns the message templates from the validator.
 
 setMessage ($messageString, $messageKey=null)
 Sets the validation failure message template for a particular key.
 
 setMessages (array $messages)
 Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.
 
 __get ($property)
 Magic function returns the value of the requested property, if and only if it is the value or a message variable.
 
 getErrors ()
 Returns array of validation failure message codes.
 
 setObscureValue ($flag)
 Set flag indicating whether or not value should be obfuscated in messages.
 
 getObscureValue ()
 Retrieve flag indicating whether or not value should be obfuscated in messages.
 
 setTranslator ($translator=null)
 Set translation object.
 
 getTranslator ()
 Return translation object.
 
 hasTranslator ()
 Does this validator have its own specific translator?
 
 setDisableTranslator ($flag)
 Indicate whether or not translation should be disabled.
 
 translatorIsDisabled ()
 Is translation disabled?
 
- Public Member Functions inherited from Zend_Validate_Interface
 isValid ($value)
 Returns true if and only if $value meets the validation requirements.
 

Public Attributes

const ERROR_NO_RECORD_FOUND = 'noRecordFound'
 Error constants.
 
const ERROR_RECORD_FOUND = 'recordFound'
 

Protected Member Functions

 _query ($value)
 Run query and returns matches, or null if no matches are found.
 
- Protected Member Functions inherited from Zend_Validate_Abstract
 _createMessage ($messageKey, $value)
 Constructs and returns a validation failure message with the given message key and value.
 
 _error ($messageKey, $value=null)
 
 _setValue ($value)
 Sets the value to be validated and clears the messages and errors arrays.
 

Protected Attributes

 $_messageTemplates
 
 $_schema = null
 
 $_table = ''
 
 $_field = ''
 
 $_exclude = null
 
 $_adapter = null
 
 $_select
 
- Protected Attributes inherited from Zend_Validate_Abstract
 $_value
 
 $_messageVariables = array()
 
 $_messageTemplates = array()
 
 $_messages = array()
 
 $_obscureValue = false
 
 $_errors = array()
 
 $_translator
 
 $_translatorDisabled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Validate_Abstract
static setDefaultTranslator ($translator=null)
 Set default translation object for all validate objects.
 
static getDefaultTranslator ()
 Get default translation object for all validate objects.
 
static hasDefaultTranslator ()
 Is there a default translation object set?
 
static getMessageLength ()
 Returns the maximum allowed message length.
 
static setMessageLength ($length=-1)
 Sets the maximum allowed message length.
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Constructor & Destructor Documentation

__construct (   $options)

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

Parameters
array | Zend_Config$optionsOptions to use for this validator

Member Function Documentation

_query (   $value)
protected

Run query and returns matches, or null if no matches are found.

Parameters
String$value
Returns
Array when matches are found.

Run query

getAdapter ( )

Returns the set adapter.

Returns
Zend_Db_Adapter

Check for an adapter being defined. if not, fetch the default adapter.

getExclude ( )

Returns the set exclude clause.

Returns
string|array
getField ( )

Returns the set field.

Returns
string|array
getSchema ( )

Returns the set schema.

Returns
string
getSelect ( )

Gets the select object to be used by the validator.

If no select object was supplied to the constructor, then it will auto-generate one from the given table, schema, field, and adapter options.

Returns
Zend_Db_Select The Select object which will be used

Build select object

getTable ( )

Returns the set table.

Returns
string
setAdapter (   $adapter)

Sets a new database adapter.

Parameters
Zend_Db_Adapter_Abstract$adapter
Returns
Zend_Validate_Db_Abstract
setExclude (   $exclude)

Sets a new exclude clause.

Parameters
string | array$exclude
Returns
Zend_Validate_Db_Abstract
setField (   $field)

Sets a new field.

Parameters
string$field
Returns
Zend_Validate_Db_Abstract
setSchema (   $schema)

Sets a new schema.

Parameters
string$schema
Returns
Zend_Validate_Db_Abstract
setSelect (   $select)

Sets the select object to be used by the validator.

Parameters
Zend_Db_Select$select
Returns
Zend_Validate_Db_Abstract
setTable (   $table)

Sets a new table.

Parameters
string$table
Returns
Zend_Validate_Db_Abstract

Member Data Documentation

$_adapter = null
protected
$_exclude = null
protected
$_field = ''
protected
$_messageTemplates
protected
Initial value:
= array(
self::ERROR_NO_RECORD_FOUND => "No record matching '%value%' was found",
self::ERROR_RECORD_FOUND => "A record matching '%value%' was found",
)
$_schema = null
protected
$_select
protected
$_table = ''
protected
const ERROR_NO_RECORD_FOUND = 'noRecordFound'

Error constants.

const ERROR_RECORD_FOUND = 'recordFound'