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
Posted by old of Satoru Yoshida (yoshida@zend.co.jp) on 2009-05-14T23:16:29.000+0000
set component and auto reassign
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-06-23T16:42:37.000+0000
Set as patch as for there's a fix available.
Posted by Jayson Santos dos Reis (jaysonsantos) on 2009-07-15T08:48:35.000+0000
Is this a valid patch ?
Posted by Jayson Santos dos Reis (jaysonsantos) on 2009-08-26T14:31:59.000+0000
Attaching a better patch to revision #17835.
Posted by Jayson Santos dos Reis (jaysonsantos) on 2009-08-26T14:42:58.000+0000
Please, consider only Mssql.php.patch