getDefaultAdapter example



    /** * Initialize database adapter. * * @return void * @throws Zend_Db_Table_Exception */
    protected function _setupDatabaseAdapter()
    {
        if ($this->_db) {
            $this->_db = self::getDefaultAdapter();
            if (!$this->_db instanceof Zend_Db_Adapter_Abstract) {
                throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this));
            }
        }
    }

    /** * Initialize table and schema names. * * If the table name is not set in the class definition, * use the class name itself as the table name. * * A schema name provided with the table name (e.g., "schema.table") overrides * any existing value for $this->_schema. * * @return void */
/** * Returns the set adapter * * @return Zend_Db_Adapter */
    public function getAdapter()
    {
        /** * 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) {
                throw new Zend_Validate_Exception('No database adapter present');
            }
        }
        return $this->_adapter;
    }

    /** * Sets a new database adapter * * @param Zend_Db_Adapter_Abstract $adapter * @return Zend_Validate_Db_Abstract */

    protected function _setDbAdapter(Zend_Db_Adapter_Abstract $zendDb = null)
    {
        $this->_zendDb = $zendDb;

        /* * If no adapter is specified, fetch default database adapter. */
        if ($this->_zendDb === null) {
            $this->_zendDb = Zend_Db_Table_Abstract::getDefaultAdapter();
            if ($this->_zendDb === null) {
                throw new Zend_Auth_Adapter_Exception('No database adapter present');
            }
        }

        return $this;
    }

    /** * _authenticateSetup() - This method abstracts the steps involved with * making sure that this adapter was indeed setup properly with all * required pieces of information. * * @throws Zend_Auth_Adapter_Exception - in the event that setup was not done properly * * @return true */
Home | Imprint | This part of the site doesn't use cookies.