Exemple #1
0
 /**
  * Constructs the validator
  * 
  * @param Zend_Config|array $config 
  * @access public
  * @return void
  */
 public function __construct($config)
 {
     parent::__construct($config);
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     }
     if (isset($config['treatment'])) {
         $this->setTreatment($config['treatment']);
     }
     if (isset($config['userPkField'])) {
         $this->setUserPkField($config['userPkField']);
     }
     if (isset($config['userPkValue'])) {
         $this->setUserPkValue($config['userPkValue']);
     }
 }
 public function __construct($IDParent = null, $IDPage = null)
 {
     parent::__construct(array('table' => 'page', 'field' => 'url', 'exclude' => isset($IDParent) ? "IDParent = '{$IDParent}'" . (isset($IDPage) ? " AND IDPage != '{$IDPage}'" : '') : null));
 }
Exemple #3
0
 /**
  * Provides basic configuration for use with \Zend_Validate_Db Validators
  * Setting $exclude allows a single record to be excluded from matching.
  * The KeyFields are fields that occur as names in the context of the form and that
  * identify the current row - that can have the value.
  * A database adapter may optionally be supplied to avoid using the registered default adapter.
  *
  * @param string|array $table The database table to validate against, or array with table and schema keys
  * @param string|array $field A field to check or an array of fields to check for an
  * unique value combination, though only the value of the first will be shown
  * @param string|array $keyFields Names of the key fields to filter out the row of the value
  * @param \Zend_Db_Adapter_Abstract $adapter An optional database adapter to use.
  */
 public function __construct($table, $field, $keyFields, \Zend_Db_Adapter_Abstract $adapter = null)
 {
     if (is_array($field)) {
         // This means a COMBINATION of fields must be unique
         foreach ($field as $dbField => $postVar) {
             if (is_int($dbField)) {
                 $this->_checkFields[$postVar] = $postVar;
             } else {
                 $this->_checkFields[$dbField] = $postVar;
             }
         }
         // Remove the first field from array, it is used as the "one" field
         // of the parent.
         $this->_postName = reset($this->_checkFields);
         $field = key($this->_checkFields);
         array_shift($this->_checkFields);
     } else {
         $this->_postName = $field;
     }
     parent::__construct($table, $field, null, $adapter);
     if (is_array($keyFields)) {
         foreach ($keyFields as $dbField => $postVar) {
             if (is_int($dbField)) {
                 $this->_keyFields[$postVar] = $postVar;
             } else {
                 $this->_keyFields[$dbField] = $postVar;
             }
         }
     } elseif ($keyFields) {
         $this->_keyFields = array($keyFields => $keyFields);
     }
 }