Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
AbstractDb Class Reference

Class for Database record validation. More...

Public Member Functions

 __construct ($options=null)
 Provides basic configuration for use with Zend Validators Setting $exclude allows a single record to be excluded from matching.
 
 getAdapter ()
 Returns the set adapter.
 
 setAdapter (DbAdapter $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 $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 AbstractValidator
 __construct ($options=null)
 Abstract constructor for all validators A validator should accept following parameters:
 
 getOption ($option)
 Returns an option.
 
 getOptions ()
 Returns all available options.
 
 setOptions ($options=[])
 Sets one or multiple options.
 
 getMessages ()
 Returns array of validation failure messages.
 
 __invoke ($value)
 Invoke as command.
 
 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.
 
 setValueObscured ($flag)
 Set flag indicating whether or not value should be obfuscated in messages.
 
 isValueObscured ()
 Retrieve flag indicating whether or not value should be obfuscated in messages.
 
 setTranslator (Translator\TranslatorInterface $translator=null, $textDomain=null)
 Set translation object.
 
 getTranslator ()
 Return translation object.
 
 hasTranslator ()
 Does this validator have its own specific translator?
 
 setTranslatorTextDomain ($textDomain= 'default')
 Set translation text domain.
 
 getTranslatorTextDomain ()
 Return the translation text domain.
 
 setTranslatorEnabled ($flag=true)
 Indicate whether or not translation should be enabled.
 
 isTranslatorEnabled ()
 Is translation enabled?
 
- Public Member Functions inherited from TranslatorAwareInterface
 setTranslator (TranslatorInterface $translator=null, $textDomain=null)
 Sets translator to use in helper.
 
- Public Member Functions inherited from ValidatorInterface
 isValid ($value)
 Returns true if and only if $value meets the validation requirements.
 
- Public Member Functions inherited from AdapterAwareInterface
 setDbAdapter (Adapter $adapter)
 Set db adapter.
 

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 AbstractValidator
 createMessage ($messageKey, $value)
 Constructs and returns a validation failure message with the given message key and value.
 
 error ($messageKey, $value=null)
 
 getValue ()
 Returns the validation value.
 
 setValue ($value)
 Sets the value to be validated and clears the messages and errors arrays.
 
 translateMessage ($messageKey, $message)
 Translate a validation message.
 

Protected Attributes

 $messageTemplates
 
 $select
 
 $schema = null
 
 $table = ''
 
 $field = ''
 
 $exclude = null
 
- Protected Attributes inherited from AbstractValidator
 $value
 
 $abstractOptions
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractValidator
static setDefaultTranslator (Translator\TranslatorInterface $translator=null, $textDomain=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 setDefaultTranslatorTextDomain ($textDomain= 'default')
 Set default translation text domain for all validate objects.
 
static getDefaultTranslatorTextDomain ()
 Get default translation text domain for all validate objects.
 
static getMessageLength ()
 Returns the maximum allowed message length.
 
static setMessageLength ($length=-1)
 Sets the maximum allowed message length.
 
- Static Protected Attributes inherited from AbstractValidator
static $defaultTranslator
 
static $defaultTranslatorTextDomain = 'default'
 
static $messageLength = -1
 

Detailed Description

Class for Database record validation.

Constructor & Destructor Documentation

__construct (   $options = null)

Provides basic configuration for use with Zend 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 | Traversable | Select$optionsOptions to use for this validator
Exceptions
\Zend\Validator\Exception\InvalidArgumentException

Member Function Documentation

getAdapter ( )

Returns the set adapter.

Exceptions
\Zend\Validator\Exception\RuntimeExceptionWhen no database adapter is defined
Returns
DbAdapter
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
Select The Select object which will be used
getTable ( )

Returns the set table.

Returns
string
query (   $value)
protected

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

Parameters
string$value
Returns
array when matches are found.
setAdapter ( DbAdapter  $adapter)

Sets a new database adapter.

Parameters
DbAdapter$adapter
Returns
self Provides a fluent interface
setExclude (   $exclude)

Sets a new exclude clause.

Parameters
string | array$exclude
Returns
self Provides a fluent interface
setField (   $field)

Sets a new field.

Parameters
string$field
Returns
AbstractDb
setSchema (   $schema)

Sets a new schema.

Parameters
string$schema
Returns
self Provides a fluent interface
setSelect ( Select  $select)

Sets the select object to be used by the validator.

Parameters
Select$select
Returns
self Provides a fluent interface
setTable (   $table)

Sets a new table.

Parameters
string$table
Returns
self Provides a fluent interface

Member Data Documentation

$exclude = null
protected
$field = ''
protected
$messageTemplates
protected
Initial value:
= [
self::ERROR_NO_RECORD_FOUND => "No record matching the input was found"
$schema = null
protected
$select
protected
$table = ''
protected
const ERROR_NO_RECORD_FOUND = 'noRecordFound'

Error constants.

const ERROR_RECORD_FOUND = 'recordFound'