Changeset 746

Show
Ignore:
Timestamp:
06/24/07 15:30:24 (1 year ago)
Author:
mikey
Message:

added unit test for net.stubbles.rdbms.pdo.stubDatabasePDOStatement

Files:

Legend:

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

    r250 r746  
    128128     *                                   the array elements must use keys corresponding to the  
    129129     *                                   number of the position or name of the parameter 
    130      * @return  bool  true on success, false on failure 
     130     * @return  stubDatabaseResult 
    131131     * @throws  stubDatabaseException 
    132132     * @see     http://php.net/pdostatement-execute 
     
    136136    { 
    137137        try { 
    138             return $this->pdoStatement->execute($values); 
     138            if (true === $this->pdoStatement->execute($values)) { 
     139                return $this; 
     140            } 
     141             
     142            throw new stubDatabaseException('Executing the prepared statement failed.'); 
    139143        } catch (PDOException $pdoe) { 
    140144            throw new stubDatabaseException($pdoe->getMessage(), $pdoe); 
     
    154158    public function fetch($fetchMode = null, array $driverOptions = array()) 
    155159    { 
    156         if (null == $fetchMode) { 
     160        if (null === $fetchMode) { 
    157161            $fetchMode = PDO::FETCH_BOTH; 
    158162        } 
     
    195199     * @see     http://php.net/pdostatement-fetchAll 
    196200     * @see     net.stubbles.rdbms.stubDatabaseResult::fetchAll() 
    197      * @todo    fix handling of $fetchMode together with $driverOptions 
    198201     */ 
    199202    public function fetchAll($fetchMode = null, array $driverOptions = array()) 
    200203    { 
    201204        try { 
    202             if (null == $fetchMode) { 
     205            if (null === $fetchMode) { 
    203206                return $this->pdoStatement->fetchAll(); 
    204207            } 
    205208             
    206             return $this->pdoStatement->fetchAll($fetchMode, ((isset($driverOptions['columnIndex']) == false) ? (null) : ($driverOptions['columnIndex']))); 
     209            if (PDO::FETCH_COLUMN == $fetchMode) { 
     210                return $this->pdoStatement->fetchAll($fetchMode, ((isset($driverOptions['columnIndex']) == false) ? (0) : ($driverOptions['columnIndex']))); 
     211            } 
     212             
     213            return $this->pdoStatement->fetchAll($fetchMode); 
    207214        } catch (PDOException $pdoe) { 
    208215            throw new stubDatabaseException($pdoe->getMessage(), $pdoe); 
  • trunk/src/main/php/net/stubbles/rdbms/stubDatabaseStatement.php

    r256 r746  
    5353     *                                   the array elements must use keys corresponding to the  
    5454     *                                   number of the position or name of the parameter 
    55      * @return  bool  true on success, false on failure 
     55     * @return  stubDatabaseResult 
    5656     * @throws  stubDatabaseException 
    5757     */ 
  • trunk/src/test/php/net/stubbles/rdbms/RDBMSTestSuite.php

    r655 r746  
    4040        // pdo 
    4141        $this->addTestFile($dir . '/pdo/stubDatabasePDOConnectionTestCase.php'); 
     42        $this->addTestFile($dir . '/pdo/stubDatabasePDOStatementTestCase.php'); 
    4243         
    4344        // persistence