Zend_Db_Adapter_Pdo_Mssql::_dsn PHP Method

_dsn() protected method

Creates a PDO DSN for the adapter from $this->_config settings.
protected _dsn ( ) : string
return string
    protected function _dsn()
    {
        // baseline of DSN parts
        $dsn = $this->_config;
        // don't pass the username and password in the DSN
        unset($dsn['username']);
        unset($dsn['password']);
        unset($dsn['options']);
        unset($dsn['persistent']);
        unset($dsn['driver_options']);
        if (isset($dsn['port'])) {
            $seperator = ':';
            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                $seperator = ',';
            }
            $dsn['host'] .= $seperator . $dsn['port'];
            unset($dsn['port']);
        }
        // this driver supports multiple DSN prefixes
        // @see http://www.php.net/manual/en/ref.pdo-dblib.connection.php
        if (isset($dsn['pdoType'])) {
            switch (strtolower($dsn['pdoType'])) {
                case 'freetds':
                case 'sybase':
                    $this->_pdoType = 'sybase';
                    break;
                case 'mssql':
                    $this->_pdoType = 'mssql';
                    break;
                case 'dblib':
                default:
                    $this->_pdoType = 'dblib';
                    break;
            }
            unset($dsn['pdoType']);
        }
        // use all remaining parts in the DSN
        foreach ($dsn as $key => $val) {
            $dsn[$key] = "{$key}={$val}";
        }
        $dsn = $this->_pdoType . ':' . implode(';', $dsn);
        return $dsn;
    }

Usage Example

Esempio n. 1
0
 protected function _dsn()
 {
     if (isset($this->_config['type'])) {
         $this->_config['pdoType'] = $this->_config['type'];
     }
     return parent::_dsn();
 }