diff options
author | robocoder <anthon.pang@gmail.com> | 2009-11-25 07:50:42 +0300 |
---|---|---|
committer | robocoder <anthon.pang@gmail.com> | 2009-11-25 07:50:42 +0300 |
commit | b3e81145346875719956918533bc4b13f49add49 (patch) | |
tree | 06fb3c1f7144c992c949eebcb5deb316d314e19c /libs/Zend/Validate | |
parent | a81a4553cc241c56d23b723770f3a12cd5fa13fa (diff) |
sync up with ZendFramework 1.9.6 which fixes ZF-8046
git-svn-id: http://dev.piwik.org/svn/trunk@1607 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/Zend/Validate')
-rw-r--r-- | libs/Zend/Validate/Db/Abstract.php | 140 | ||||
-rw-r--r-- | libs/Zend/Validate/Db/RecordExists.php | 50 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Crc32.php | 2 | ||||
-rw-r--r-- | libs/Zend/Validate/Hostname/Com.php | 2 |
4 files changed, 97 insertions, 97 deletions
diff --git a/libs/Zend/Validate/Db/Abstract.php b/libs/Zend/Validate/Db/Abstract.php index e5103ff4ed..de5a863ea8 100644 --- a/libs/Zend/Validate/Db/Abstract.php +++ b/libs/Zend/Validate/Db/Abstract.php @@ -1,5 +1,5 @@ -<?php - +<?php + /** * Zend Framework * @@ -17,104 +17,104 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 17160 2009-07-26 19:46:24Z bittarman $ - */ - + * @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $ + */ + /** * @see Zend_Validate_Abstract - */ -require_once 'Zend/Validate/Abstract.php'; - + */ +require_once 'Zend/Validate/Abstract.php'; + /** * Class for Database record validation - * + * * @category Zend * @package Zend_Validate * @uses Zend_Validate_Abstract * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract -{ + */ +abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract +{ /** * Error constants - */ - const ERROR_NO_RECORD_FOUND = 'noRecordFound'; - const ERROR_RECORD_FOUND = 'recordFound'; - + */ + const ERROR_NO_RECORD_FOUND = 'noRecordFound'; + const ERROR_RECORD_FOUND = 'recordFound'; + /** * @var array Message templates - */ - protected $_messageTemplates = array(self::ERROR_NO_RECORD_FOUND => 'No record matching %value% was found', - self::ERROR_RECORD_FOUND => 'A record matching %value% was found'); + */ + protected $_messageTemplates = array(self::ERROR_NO_RECORD_FOUND => 'No record matching %value% was found', + self::ERROR_RECORD_FOUND => 'A record matching %value% was found'); /** * @var string - */ + */ protected $_schema = null; - + /** * @var string - */ - protected $_table = ''; - + */ + protected $_table = ''; + /** * @var string - */ - protected $_field = ''; - + */ + protected $_field = ''; + /** * @var mixed - */ - protected $_exclude = null; - + */ + protected $_exclude = null; + /** * Database adapter to use. If null isValid() will use Zend_Db::getInstance instead * * @var unknown_type - */ - protected $_adapter = null; - + */ + protected $_adapter = null; + /** - * Provides basic configuration for use with Zend_Validate_Db Validators + * 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. - * + * to define the where clause added to the sql. + * 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 $field The field to check for a match * @param string||array $exclude An optional where clause or field/value pair to exclude from the query * @param Zend_Db_Adapter_Abstract $adapter An optional database adapter to use. - */ - public function __construct($table, $field, $exclude = null, Zend_Db_Adapter_Abstract $adapter = null) - { - if ($adapter !== null) { - $this->_adapter = $adapter; - } - $this->_exclude = $exclude; - $this->_field = (string) $field; - + */ + public function __construct($table, $field, $exclude = null, Zend_Db_Adapter_Abstract $adapter = null) + { + if ($adapter !== null) { + $this->_adapter = $adapter; + } + $this->_exclude = $exclude; + $this->_field = (string) $field; + if (is_array($table)) { $this->_table = (isset($table['table'])) ? $table['table'] : ''; - $this->_schema = (isset($table['schema'])) ? $table['schema'] : null; + $this->_schema = (isset($table['schema'])) ? $table['schema'] : null; } else { - $this->_table = (string) $table; + $this->_table = (string) $table; } - } - + } + /** * Run query and returns matches, or null if no matches are found. * * @param String $value * @return Array when matches are found. - */ - protected function _query($value) - { + */ + protected function _query($value) + { /** * Check for an adapter being defined. if not, fetch the default adapter. - */ + */ if ($this->_adapter === null) { $this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); if (null === $this->_adapter) { @@ -125,24 +125,24 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract /** * Build select object - */ + */ $select = new Zend_Db_Select($this->_adapter); $select->from($this->_table, array($this->_field), $this->_schema) - ->where($this->_adapter->quoteIdentifier($this->_field).' = ?', $value); - if ($this->_exclude !== null) { - if (is_array($this->_exclude)) { - $select->where($this->_adapter->quoteIdentifier($this->_exclude['field']).' != ?', $this->_exclude['value']); - } else { - $select->where($this->_exclude); - } - } - $select->limit(1); - + ->where($this->_adapter->quoteIdentifier($this->_field).' = ?', $value); + if ($this->_exclude !== null) { + if (is_array($this->_exclude)) { + $select->where($this->_adapter->quoteIdentifier($this->_exclude['field']).' != ?', $this->_exclude['value']); + } else { + $select->where($this->_exclude); + } + } + $select->limit(1); + /** * Run query - */ - $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); - - return $result; - } + */ + $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); + + return $result; + } } diff --git a/libs/Zend/Validate/Db/RecordExists.php b/libs/Zend/Validate/Db/RecordExists.php index 2d753e4b0a..22f39bc6a0 100644 --- a/libs/Zend/Validate/Db/RecordExists.php +++ b/libs/Zend/Validate/Db/RecordExists.php @@ -1,5 +1,5 @@ <?php - + /** * Zend Framework * @@ -17,37 +17,37 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RecordExists.php 16971 2009-07-22 18:05:45Z mikaelkael $ - */ - - + * @version $Id: RecordExists.php 18951 2009-11-12 16:26:19Z alexander $ + */ + + /** * @see Zend_Validate_Db_Abstract - */ -require_once 'Zend/Validate/Db/Abstract.php'; - + */ +require_once 'Zend/Validate/Db/Abstract.php'; + /** * Confirms a record exists in a table. - * + * * @category Zend * @package Zend_Validate * @uses Zend_Validate_Db_Abstract * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Validate_Db_RecordExists extends Zend_Validate_Db_Abstract -{ - public function isValid($value) - { - $valid = true; - $this->_setValue($value); - - $result = $this->_query($value); - if (!$result) { - $valid = false; - $this->_error(self::ERROR_NO_RECORD_FOUND); - } - - return $valid; - } + */ +class Zend_Validate_Db_RecordExists extends Zend_Validate_Db_Abstract +{ + public function isValid($value) + { + $valid = true; + $this->_setValue($value); + + $result = $this->_query($value); + if (!$result) { + $valid = false; + $this->_error(self::ERROR_NO_RECORD_FOUND); + } + + return $valid; + } } diff --git a/libs/Zend/Validate/File/Crc32.php b/libs/Zend/Validate/File/Crc32.php index fd46d81b6b..80ed0ce6d1 100644 --- a/libs/Zend/Validate/File/Crc32.php +++ b/libs/Zend/Validate/File/Crc32.php @@ -176,4 +176,4 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash return $this->_throw($file, self::DOES_NOT_MATCH); } -}
\ No newline at end of file +} diff --git a/libs/Zend/Validate/Hostname/Com.php b/libs/Zend/Validate/Hostname/Com.php index 19290b300f..929d8b0f0c 100644 --- a/libs/Zend/Validate/Hostname/Com.php +++ b/libs/Zend/Validate/Hostname/Com.php @@ -195,4 +195,4 @@ return array( 79 => '/^[\x{20000}-\x{2A6DF}]{1,63}$/iu', 80 => '/^[\x{2F800}-\x{2FA1F}]{1,63}$/iu' -);
\ No newline at end of file +); |