/** * 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) { /** * 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) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('No database adapter present'); } } /** * 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); /** * Run query */ $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); return $result; }
/** * 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) { /** * Check for an adapter being defined. if not, fetch the default adapter. */ if ($this->_adapter === null) { $this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); } /** * Build select object */ $select = new Zend_Db_Select($this->_adapter); $select->from($this->_table, array($this->_field))->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; }
/** * * (non-PHPdoc) * @see Crud/Controller/Fgsl_Crud_Controller_Interface#editAction() */ public function editAction() { $fieldKey = $this->_model->getFieldKey(); $record = $this->_model->fetchRow("{$fieldKey} = {$this->_getParam($fieldKey)}"); $_POST = array(); foreach ($this->_fieldNames as $fieldName) { if (isset($record->{$fieldName})) { $_POST[$fieldName] = $record->{$fieldName}; } } Fgsl_Session_Namespace::set('post', new Zend_Filter_Input(null, null, $_POST)); $this->_forward('insert'); }