Changeset 1754

Show
Ignore:
Timestamp:
07/31/08 14:29:57 (4 months ago)
Author:
mikey
Message:

fix problem with empty driver options overriding default settings provided by PDO

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework/trunk/src/main/php/net/stubbles/rdbms/pdo/stubDatabasePDOConnection.php

    • Property svn:keywords set to Id
    r1281 r1754  
    66 * @package     stubbles 
    77 * @subpackage  rdbms_pdo 
     8 * @version     $Id$ 
    89 */ 
    910stubClassLoader::load('net::stubbles::rdbms::stubDatabaseConnection', 
     
    8182    protected function createPDO() 
    8283    { 
    83         $this->pdo = new PDO($this->connectionData->getDSN(), 
    84                              $this->connectionData->getUserName(), 
    85                              $this->connectionData->getPassword(), 
    86                              $this->connectionData->getDriverOptions() 
    87                      ); 
     84        $driverOptions = $this->connectionData->getDriverOptions(); 
     85        if (count($driverOptions) === 0) { 
     86            $this->pdo = new PDO($this->connectionData->getDSN(), 
     87                                 $this->connectionData->getUserName(), 
     88                                 $this->connectionData->getPassword() 
     89                         ); 
     90        } else { 
     91            $this->pdo = new PDO($this->connectionData->getDSN(), 
     92                                 $this->connectionData->getUserName(), 
     93                                 $this->connectionData->getPassword(), 
     94                                 $driverOptions 
     95                         ); 
     96        } 
    8897    } 
    8998 
     
    217226                    case PDO::FETCH_COLUMN: 
    218227                        if (isset($driverOptions['colNo']) == false) { 
    219                             throw new stubDatabaseException('Fetch mode COLUMN requires driver option ŽcolNoŽ.'); 
     228                            throw new stubDatabaseException('Fetch mode COLUMN requires driver option ᅵcolNoᅵ.'); 
    220229                        } 
    221230                         
     
    225234                    case PDO::FETCH_INTO: 
    226235                        if (isset($driverOptions['object']) == false) { 
    227                             throw new stubDatabaseException('Fetch mode INTO requires driver option ŽobjectŽ.'); 
     236                            throw new stubDatabaseException('Fetch mode INTO requires driver option ᅵobjectᅵ.'); 
    228237                        } 
    229238                         
     
    233242                    case PDO::FETCH_CLASS: 
    234243                        if (isset($driverOptions['classname']) == false) { 
    235                             throw new stubDatabaseException('Fetch mode CLASS requires driver option ŽclassnameŽ.'); 
     244                            throw new stubDatabaseException('Fetch mode CLASS requires driver option ᅵclassnameᅵ.'); 
    236245                        } 
    237246                         
  • framework/trunk/src/test/php/net/stubbles/rdbms/pdo/stubDatabasePDOConnectionTestCase.php

    • Property svn:keywords set to Id
    r1703 r1754  
    66 * @package     stubbles 
    77 * @subpackage  rdbms_test 
     8 * @version     $Id$ 
    89 */ 
    910stubClassLoader::load('net::stubbles::rdbms::pdo::stubDatabasePDOConnection'); 
    1011if (extension_loaded('pdo') == true) { 
     12    /** 
     13     * Helper class for the test. 
     14     * 
     15     * @package     stubbles 
     16     * @subpackage  rdbms_test 
     17     */ 
    1118    class TestPDOStatement extends PDOStatement {} 
    1219} 
     20/** 
     21 * Helper class for the test. 
     22 * 
     23 * @package     stubbles 
     24 * @subpackage  rdbms_test 
     25 */ 
    1326class TeststubDatabasePDOConnection extends stubDatabasePDOConnection 
    1427{