_dsn example


    protected function _connect()
    {
        // if we already have a PDO object, no need to re-connect.         if ($this->_connection) {
            return;
        }

        // get the dsn first, because some adapters alter the $_pdoType         $dsn = $this->_dsn();

        // check for PDO extension         if (!extension_loaded('pdo')) {
            /** * @see Zend_Db_Adapter_Exception */
            throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
        }

        // check the PDO driver is available         if (!in_array($this->_pdoType, PDO::getAvailableDrivers())) {
            
'DOUBLE PRECISION'   => Zend_Db::FLOAT_TYPE,
        'FIXED'              => Zend_Db::FLOAT_TYPE,
        'FLOAT'              => Zend_Db::FLOAT_TYPE
    );

    /** * Override _dsn() and ensure that charset is incorporated in mysql * @see Zend_Db_Adapter_Pdo_Abstract::_dsn() */
    protected function _dsn()
    {
        $dsn = parent::_dsn();
        if (isset($this->_config['charset'])) {
            $dsn .= ';charset=' . $this->_config['charset'];
        }
        return $dsn;
    }
    
    /** * Creates a PDO object and connects to the database. * * @return void * @throws Zend_Db_Adapter_Exception */
Home | Imprint | This part of the site doesn't use cookies.