Issues

ZF-6666: pdoType on Zend_Db_Adapter_Pdo_Mssql could be guessed automaticaly

Issue Type: Patch Created: 2009-05-14T20:32:06.000+0000 Last Updated: 2013-03-13T20:55:24.000+0000 Status: Open Fix version(s): - Next Mini Release ()

Reporter: Alexandre Gomes Gaigalas (alganet) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db

Related issues: Attachments: - Mssql.php.patch

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:

<pre class="highlight">
//

        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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts