ZF-6666: pdoType on Zend_Db_Adapter_Pdo_Mssql could be guessed automaticaly

Description

Its possible to determine the pdoType using something like this:

$avaliableDrivers = PDO::getAvailableDrivers(); $suitedDrivers = array('mssql', 'dblib', 'sybase'); $avaliableSuitedDrivers = array_intersect($avaliableDrivers, $suitedDrivers); $bestDriver = array_shift($avaliableSuitedDrivers);

Scripts using such algorithm could run on any enabled plataform without changing any configuration.

Sample Zend_Db_Adapter_Pdo_Mssql modification:


//

        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']);
        } else {
            $avaliableDrivers = PDO::getAvailableDrivers();
            $avaliableSuitedDrivers = array_intersect($avaliableDrivers, array('mssql', 'dblib', 'sybase'));
            if (count($avaliableSuitedDrivers)) {
                $this->_pdoType = array_shift($avaliableSuitedDrivers);
            }
        }

Comments

set component and auto reassign

Set as patch as for there's a fix available.

Is this a valid patch ?

Attaching a better patch to revision #17835.

Please, consider only Mssql.php.patch