--- library/Zend/Validate/Db/Abstract.php (revision 18383) +++ library/Zend/Validate/Db/Abstract.php (working copy) @@ -145,14 +145,16 @@ } } + /** - * Run query and returns matches, or null if no matches are found. + * Get Db Adapter * - * @param String $value - * @return Array when matches are found. + * @return Zend_Db_Adapter_Abstract + * @throws Zend_Validate_Exception */ - protected function _query($value) - { + + + public function getAdapter(){ /** * Check for an adapter being defined. if not, fetch the default adapter. */ @@ -164,15 +166,30 @@ } } + return $this->_adapter; + + } + + /** + * 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) + { + + $adapter = $this->getAdapter(); + /** * Build select object */ - $select = new Zend_Db_Select($this->_adapter); + $select = new Zend_Db_Select($adapter); $select->from($this->_table, array($this->_field), $this->_schema) - ->where($this->_adapter->quoteIdentifier($this->_field).' = ?', $value); + ->where($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']); + $select->where($adapter->quoteIdentifier($this->_exclude['field']).' != ?', $this->_exclude['value']); } else { $select->where($this->_exclude); } @@ -182,7 +199,7 @@ /** * Run query */ - $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); + $result = $adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); return $result; }