Definition at line 36 of file Abstract.php.
◆ __construct()
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 | $options | Options to use for this validator |
- Exceptions
-
Definition at line 102 of file Abstract.php.
110 }
else if (func_num_args() > 1) {
112 $temp[
'table'] = array_shift(
$options);
113 $temp[
'field'] = array_shift(
$options);
115 $temp[
'exclude'] = array_shift(
$options);
119 $temp[
'adapter'] = array_shift(
$options);
125 if (!array_key_exists(
'table',
$options) && !array_key_exists(
'schema',
$options)) {
126 #require_once 'Zend/Validate/Exception.php'; 130 if (!array_key_exists(
'field',
$options)) {
131 #require_once 'Zend/Validate/Exception.php'; 135 if (array_key_exists(
'adapter',
$options)) {
139 if (array_key_exists(
'exclude',
$options)) {
144 if (array_key_exists(
'table',
$options)) {
148 if (array_key_exists(
'schema',
$options)) {
◆ _query()
Run query and returns matches, or null if no matches are found.
- Parameters
-
- Returns
- Array when matches are found.
Run query
Definition at line 341 of file Abstract.php.
◆ getAdapter()
Returns the set adapter
- Exceptions
-
- Returns
- Zend_Db_Adapter
Check for an adapter being defined. if not, fetch the default adapter.
Definition at line 159 of file Abstract.php.
164 if ($this->_adapter ===
null) {
166 if (
null === $this->_adapter) {
167 #require_once 'Zend/Validate/Exception.php';
static getDefaultAdapter()
◆ getExclude()
Returns the set exclude clause
- Returns
- string|array
Definition at line 197 of file Abstract.php.
◆ getField()
Returns the set field
- Returns
- string|array
Definition at line 219 of file Abstract.php.
◆ getSchema()
Returns the set schema
- Returns
- string
Definition at line 263 of file Abstract.php.
◆ 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
Definition at line 305 of file Abstract.php.
307 if (
null === $this->_select) {
313 $select->from($this->_table, array($this->_field), $this->_schema);
314 if ($db->supportsParameters(
'named')) {
315 $select->where($db->quoteIdentifier($this->_field,
true).
' = :value');
317 $select->where($db->quoteIdentifier($this->_field,
true).
' = ?');
319 if ($this->_exclude !==
null) {
320 if (is_array($this->_exclude)) {
322 $db->quoteIdentifier($this->_exclude[
'field'],
true) .
323 ' != ?', $this->_exclude[
'value']
326 $select->where($this->_exclude);
◆ getTable()
Returns the set table
- Returns
- string
Definition at line 241 of file Abstract.php.
◆ setAdapter()
◆ setExclude()
◆ setField()
◆ setSchema()
◆ setSelect()
◆ setTable()
◆ $_adapter
◆ $_exclude
◆ $_field
◆ $_messageTemplates
Initial value:= array(
self::ERROR_NO_RECORD_FOUND => "No record matching '%value%' was found",
self::ERROR_RECORD_FOUND => "A record matching '%value%' was found",
)
Definition at line 47 of file Abstract.php.
◆ $_schema
◆ $_select
◆ $_table
◆ ERROR_NO_RECORD_FOUND
const ERROR_NO_RECORD_FOUND = 'noRecordFound' |
◆ ERROR_RECORD_FOUND
const ERROR_RECORD_FOUND = 'recordFound' |
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Validate/Db/Abstract.php