Changeset 4036

Show
Ignore:
Timestamp:
03/19/08 05:28:31 (16 months ago)
Author:
jwage
Message:

fixes #833 - also cleaned up and added doc blocks for all adapter module code.

Location:
branches/0.10/lib/Doctrine
Files:
2 removed
8 modified

Legend:

Unmodified
Added
Removed
  • branches/0.10/lib/Doctrine/Adapter/Db2.php

    r3884 r4036  
    3535{ 
    3636    /** 
     37     * _config 
     38     * 
    3739     * User-provided configuration. 
    3840     * 
     
    6062 
    6163    /** 
     64     * _executeMode 
     65     * 
    6266     * Execution mode 
    6367     * 
     
    6569     * @access protected 
    6670     */ 
    67     protected $_execute_mode = DB2_AUTOCOMMIT_ON; 
    68  
    69     /** 
     71    protected $_executeMode = DB2_AUTOCOMMIT_ON; 
     72 
     73    /** 
     74     * _lastInsertTable 
     75     * 
    7076     * Table name of the last accessed table for an insert operation 
    7177     * This is a DB2-Adapter-specific member variable with the utmost 
     
    7884 
    7985     /** 
    80      * Constructor. 
     86     * __construct 
    8187     * 
    8288     * $config is an array of key/value pairs containing configuration 
     
    97103    { 
    98104        if ( ! isset($config['password'])) { 
    99             throw new Doctrine_Adapter_Db2_Exception("Configuration array must have a key for 'password' for login credentials."); 
     105            throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'password' for login credentials."); 
    100106        } 
    101107 
    102108        if ( ! isset($config['username'])) { 
    103             throw new Doctrine_Adapter_Db2_Exception("Configuration array must have a key for 'username' for login credentials."); 
     109            throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'username' for login credentials."); 
    104110        } 
    105111 
    106112        if ( ! isset($config['dbname'])) { 
    107             throw new Doctrine_Adapter_Db2_Exception("Configuration array must have a key for 'dbname' that names the database instance."); 
     113            throw new Doctrine_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance."); 
    108114        } 
    109115 
    110116        // keep the config 
    111117        $this->_config = array_merge($this->_config, (array) $config); 
    112  
    113         // create a profiler object 
    114         $enabled = false; 
    115         if (array_key_exists('profiler', $this->_config)) { 
    116             $enabled = (bool) $this->_config['profiler']; 
    117             unset($this->_config['profiler']); 
    118         } 
    119  
    120         $this->_profiler = new Doctrine_Profiler($enabled); 
    121     } 
    122  
    123     /** 
     118    } 
     119 
     120    /** 
     121     * _connect 
     122     * 
    124123     * Creates a connection resource. 
    125124     * 
     
    134133 
    135134        if ( ! extension_loaded('ibm_db2')) { 
    136             throw new Doctrine_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but not loaded'); 
     135            throw new Doctrine_Adapter_Exception('The IBM DB2 extension is required for this adapter but not loaded'); 
    137136        } 
    138137 
     
    152151        if ( ! isset($this->_config['options']['autocommit'])) { 
    153152            // set execution mode 
    154             $this->_config['options']['autocommit'] = &$this->_execute_mode; 
     153            $this->_config['options']['autocommit'] = &$this->_executeMode; 
    155154        } 
    156155 
     
    182181        // check the connection 
    183182        if ( ! $this->_connection) { 
    184             throw new Doctrine_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error()); 
    185         } 
    186     } 
    187  
    188     /** 
     183            throw new Doctrine_Adapter_Exception(db2_conn_errormsg(), db2_conn_error()); 
     184        } 
     185    } 
     186 
     187    /** 
     188     * closeConnection 
     189     * 
    189190     * Force the connection to close. 
    190191     * 
     
    198199 
    199200    /** 
     201     * prepare 
     202     * 
    200203     * Returns an SQL statement for preparation. 
    201204     * 
     
    212215 
    213216    /** 
     217     * _getExecuteMode 
     218     * 
    214219     * Gets the execution mode 
    215220     * 
     
    218223    public function _getExecuteMode() 
    219224    { 
    220         return $this->_execute_mode; 
    221     } 
    222  
    223     /** 
     225        return $this->_executeMode; 
     226    } 
     227 
     228    /** 
     229     * _setExecuteMode 
     230     * 
    224231     * @param integer $mode 
    225232     * @return void 
     
    230237            case DB2_AUTOCOMMIT_OFF: 
    231238            case DB2_AUTOCOMMIT_ON: 
    232                 $this->_execute_mode = $mode; 
     239                $this->_executeMode = $mode; 
    233240                db2_autocommit($this->_connection, $mode); 
    234241                break; 
    235242            default: 
    236                 throw new Doctrine_Adapter_Db2_Exception("execution mode not supported"); 
     243                throw new Doctrine_Adapter_Exception("execution mode not supported"); 
    237244                break; 
    238245        } 
     
    240247 
    241248    /** 
     249     * _quote 
     250     * 
    242251     * Quote a raw string. 
    243252     * 
     
    261270 
    262271    /** 
     272     * getQuoteIdentifierSymbol 
     273     * 
    263274     * @return string 
    264275     */ 
     
    271282 
    272283    /** 
     284     * _beginTransaction 
     285     * 
    273286     * Begin a transaction. 
    274287     * 
     
    281294 
    282295    /** 
     296     * _commit 
     297     * 
    283298     * Commit a transaction. 
    284299     * 
     
    288303    { 
    289304        if ( ! db2_commit($this->_connection)) { 
    290             throw new Doctrine_Adapter_Db2_Exception( 
     305            throw new Doctrine_Adapter_Exception( 
    291306                db2_conn_errormsg($this->_connection), 
    292307                db2_conn_error($this->_connection)); 
     
    297312 
    298313    /** 
     314     * _rollBack 
     315     * 
    299316     * Rollback a transaction. 
    300317     * 
     
    304321    { 
    305322        if ( ! db2_rollback($this->_connection)) { 
    306             throw new Doctrine_Adapter_Db2_Exception( 
     323            throw new Doctrine_Adapter_Exception( 
    307324                db2_conn_errormsg($this->_connection), 
    308325                db2_conn_error($this->_connection)); 
     
    312329 
    313330    /** 
     331     * setFetchMode 
     332     * 
    314333     * Set the fetch mode. 
    315334     * 
     
    327346                break; 
    328347            default: 
    329                 throw new Doctrine_Adapter_Db2_Exception('Invalid fetch mode specified'); 
     348                throw new Doctrine_Adapter_Exception('Invalid fetch mode specified'); 
    330349                break; 
    331350        } 
  • branches/0.10/lib/Doctrine/Adapter/Interface.php

    r3884 r4036  
    3232 * @version     $Revision$ 
    3333 */ 
    34 interface Doctrine_Adapter_Interface { 
     34interface Doctrine_Adapter_Interface 
     35{ 
    3536    public function prepare($prepareString); 
    3637    public function query($queryString); 
  • branches/0.10/lib/Doctrine/Adapter/Mock.php

    r3950 r4036  
    2222/** 
    2323 * Doctrine_Adapter_Mock 
     24 * 
    2425 * This class is used for special testing purposes. 
    2526 * 
     
    3435class Doctrine_Adapter_Mock implements Doctrine_Adapter_Interface, Countable 
    3536{ 
    36     private $name; 
     37    private $_name; 
    3738     
    38     private $queries = array(); 
     39    private $_queries = array(); 
    3940     
    40     private $exception = array(); 
     41    private $_exception = array(); 
    4142     
    42     private $lastInsertIdFail = false; 
     43    private $_lastInsertIdFail = false; 
    4344 
    4445    public function __construct($name = null)  
    4546    { 
    46         $this->name = $name; 
     47        $this->_name = $name; 
    4748    } 
    4849    public function getName()  
    4950    { 
    50         return $this->name; 
     51        return $this->_name; 
    5152    } 
    5253    public function pop()  
    5354    { 
    54         return array_pop($this->queries); 
     55        return array_pop($this->_queries); 
    5556    } 
    5657    public function forceException($name, $message = '', $code = 0)  
    5758    { 
    58         $this->exception = array($name, $message, $code); 
     59        $this->_exception = array($name, $message, $code); 
    5960    } 
    6061    public function prepare($query) 
     
    6768    public function addQuery($query) 
    6869    { 
    69         $this->queries[] = $query; 
     70        $this->_queries[] = $query; 
    7071    } 
    7172    public function query($query)  
    7273    { 
    73         $this->queries[] = $query; 
     74        $this->_queries[] = $query; 
    7475 
    75         $e    = $this->exception; 
     76        $e    = $this->_exception; 
    7677 
    7778        if ( ! empty($e)) { 
    7879            $name = $e[0]; 
    7980 
    80             $this->exception = array(); 
     81            $this->_exception = array(); 
    8182 
    8283            throw new $name($e[1], $e[2]); 
     
    9091    public function getAll()  
    9192    { 
    92         return $this->queries; 
     93        return $this->_queries; 
    9394    } 
    9495    public function quote($input)  
     
    9899    public function exec($statement)  
    99100    { 
    100         $this->queries[] = $statement; 
     101        $this->_queries[] = $statement; 
    101102 
    102         $e    = $this->exception; 
     103        $e    = $this->_exception; 
    103104 
    104105        if ( ! empty($e)) { 
    105106            $name = $e[0]; 
    106107 
    107             $this->exception = array(); 
     108            $this->_exception = array(); 
    108109 
    109110            throw new $name($e[1], $e[2]); 
     
    115116    { 
    116117        if ($fail) { 
    117             $this->lastInsertIdFail = true; 
     118            $this->_lastInsertIdFail = true; 
    118119        } else { 
    119             $this->lastInsertIdFail = false; 
     120            $this->_lastInsertIdFail = false; 
    120121        } 
    121122    } 
    122123    public function lastInsertId() 
    123124    { 
    124         $this->queries[] = 'LAST_INSERT_ID()'; 
    125         if ($this->lastInsertIdFail) { 
     125        $this->_queries[] = 'LAST_INSERT_ID()'; 
     126        if ($this->_lastInsertIdFail) { 
    126127            return null; 
    127128        } else { 
     
    131132    public function count()  
    132133    { 
    133         return count($this->queries);     
     134        return count($this->_queries);     
    134135    } 
    135136    public function beginTransaction() 
    136137    { 
    137         $this->queries[] = 'BEGIN TRANSACTION'; 
     138        $this->_queries[] = 'BEGIN TRANSACTION'; 
    138139    } 
    139140    public function commit() 
    140141    { 
    141         $this->queries[] = 'COMMIT'; 
     142        $this->_queries[] = 'COMMIT'; 
    142143    } 
    143144    public function rollBack()  
    144145    { 
    145         $this->queries[] = 'ROLLBACK'; 
     146        $this->_queries[] = 'ROLLBACK'; 
    146147    } 
    147148    public function errorCode()  
     
    151152    public function getAttribute($attribute)  
    152153    { 
    153         if ($attribute == Doctrine::ATTR_DRIVER_NAME) 
    154             return strtolower($this->name); 
     154        if ($attribute == Doctrine::ATTR_DRIVER_NAME) { 
     155            return strtolower($this->_name); 
     156        } 
    155157    } 
    156158    public function setAttribute($attribute, $value)  
  • branches/0.10/lib/Doctrine/Adapter/Mysqli.php

    r3884 r4036  
    3535{ 
    3636    /** 
     37     * _connect 
     38     * 
    3739     * Creates a connection to the database. 
    3840     * 
    3941     * @return void 
    40      * @throws Doctrine_Adapter_Mysqli_Exception 
     42     * @throws Doctrine_Adapter_Exception 
    4143     */ 
    4244    protected function _connect() 
     
    5456        ); 
    5557        if ($this->_connection === false || mysqli_connect_errno()) { 
    56             throw new Doctrine_Adapter_Mysqli_Exception(mysqli_connect_error()); 
     58            throw new Doctrine_Adapter_Exception(mysqli_connect_error()); 
    5759        } 
    5860    } 
    5961 
    6062    /** 
     63     * closeConnection 
     64     * 
    6165     * Force the connection to close. 
    6266     * 
     
    7074 
    7175    /** 
     76     * prepare 
     77     * 
    7278     * Prepare a statement and return a PDOStatement-like object. 
    7379     * 
     
    8490 
    8591    /** 
     92     * lastInsertId 
     93     * 
    8694     * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column. 
    8795     * 
     
    106114 
    107115    /** 
     116     * _beginTransaction 
     117     * 
    108118     * Begin a transaction. 
    109119     * 
     
    117127 
    118128    /** 
     129     * _commit 
     130     * 
    119131     * Commit a transaction. 
    120132     * 
     
    129141 
    130142    /** 
     143     * _rollBack 
     144     * 
    131145     * Roll-back a transaction. 
    132146     * 
  • branches/0.10/lib/Doctrine/Adapter/Oracle.php

    r3884 r4036  
    3535{ 
    3636    /** 
     37     * _config 
     38     * 
    3739     * User-provided configuration. 
    3840     * 
     
    5355 
    5456    /** 
     57     * _executeMode 
     58     * 
    5559     * @var integer 
    5660     */ 
    57     protected $_execute_mode = OCI_COMMIT_ON_SUCCESS; 
    58  
    59     /** 
    60      * Constructor. 
     61    protected $_executeMode = OCI_COMMIT_ON_SUCCESS; 
     62 
     63    /** 
     64     * __construct 
    6165     * 
    6266     * $config is an array of key/value pairs containing configuration 
     
    7781        } 
    7882 
    79         // @todo Let this protect backward-compatibility for one release, then remove 
    80         if ( ! isset($config['database']) || ! isset($config['dbname'])) { 
    81             $config['dbname'] = $config['database']; 
    82             unset($config['database']); 
    83             trigger_error("Deprecated config key 'database', use 'dbname' instead.", E_USER_NOTICE); 
    84         } 
    85  
    8683        // keep the config 
    8784        $this->_config = array_merge($this->_config, (array) $config); 
    88  
    89         // create a profiler object 
    90         $enabled = false; 
    91         if (array_key_exists('profiler', $this->_config)) { 
    92             $enabled = (bool) $this->_config['profiler']; 
    93             unset($this->_config['profiler']); 
    94         } 
    95  
    96         $this->_profiler = new Doctrine_Profiler($enabled); 
    97     } 
    98  
    99     /** 
     85    } 
     86 
     87    /** 
     88     * _connect 
     89     * 
    10090     * Creates a connection resource. 
    10191     * 
    10292     * @return void 
    103      * @throws Doctrine_Adapter_Oracle_Exception 
     93     * @throws Doctrine_Adapter_Exception 
    10494     */ 
    10595    protected function _connect() 
     
    111101 
    112102        if ( ! extension_loaded('oci8')) { 
    113             throw new Doctrine_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but not loaded'); 
     103            throw new Doctrine_Adapter_Exception('The OCI8 extension is required for this adapter but not loaded'); 
    114104        } 
    115105 
     
    127117        // check the connection 
    128118        if ( ! $this->_connection) { 
    129             throw new Doctrine_Adapter_Oracle_Exception(oci_error()); 
    130         } 
    131     } 
    132  
    133     /** 
     119            throw new Doctrine_Adapter_Exception(oci_error()); 
     120        } 
     121    } 
     122 
     123    /** 
     124     * closeConnection 
     125     * 
    134126     * Force the connection to close. 
    135127     * 
     
    145137 
    146138    /** 
     139     * prepare 
     140     * 
    147141     * Returns an SQL statement for preparation. 
    148142     * 
     
    159153 
    160154    /** 
     155     * _quote 
     156     * 
    161157     * Quote a raw string. 
    162158     * 
     
    171167 
    172168    /** 
     169     * quoteTableAs 
     170     * 
    173171     * Quote a table identifier and alias. 
    174172     * 
     
    184182 
    185183    /** 
     184     * _beginTransaction 
     185     * 
    186186     * Leave autocommit mode and begin a transaction. 
    187187     * 
     
    194194 
    195195    /** 
     196     * _commit 
     197     * 
    196198     * Commit a transaction and return to autocommit mode. 
    197199     * 
    198200     * @return void 
    199      * @throws Doctrine_Adapter_Oracle_Exception 
     201     * @throws Doctrine_Adapter_Exception 
    200202     */ 
    201203    protected function _commit() 
    202204    { 
    203205        if ( ! oci_commit($this->_connection)) { 
    204             throw new Doctrine_Adapter_Oracle_Exception(oci_error($this->_connection)); 
     206            throw new Doctrine_Adapter_Exception(oci_error($this->_connection)); 
    205207        } 
    206208        $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); 
     
    208210 
    209211    /** 
     212     * _rollBack 
     213     * 
    210214     * Roll back a transaction and return to autocommit mode. 
    211215     * 
    212216     * @return void 
    213      * @throws Doctrine_Adapter_Oracle_Exception 
     217     * @throws Doctrine_Adapter_Exception 
    214218     */ 
    215219    protected function _rollBack() 
    216220    { 
    217221        if ( ! oci_rollback($this->_connection)) { 
    218             throw new Doctrine_Adapter_Oracle_Exception(oci_error($this->_connection)); 
     222            throw new Doctrine_Adapter_Exception(oci_error($this->_connection)); 
    219223        } 
    220224        $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); 
     
    222226 
    223227    /** 
     228     * setFetchMode 
     229     * 
    224230     * Set the fetch mode. 
    225231     * 
     
    246252 
    247253    /** 
     254     * _setExecuteMode 
     255     * 
    248256     * @param integer $mode 
    249257     * @throws Doctrine_Adapter_Exception 
     
    255263            case OCI_DEFAULT: 
    256264            case OCI_DESCRIBE_ONLY: 
    257                 $this->_execute_mode = $mode; 
     265                $this->_executeMode = $mode; 
    258266                break; 
    259267            default: 
     
    264272 
    265273    /** 
    266      * @return 
     274     * _getExecuteMode 
     275     * 
     276     * @return integer $mode 
    267277     */ 
    268278    public function _getExecuteMode() 
    269279    { 
    270         return $this->_execute_mode; 
     280        return $this->_executeMode; 
    271281    } 
    272282} 
  • branches/0.10/lib/Doctrine/Adapter/Statement.php

    r3884 r4036  
    3333abstract class Doctrine_Adapter_Statement 
    3434{ 
     35    /** 
     36     * bindValue 
     37     * 
     38     * @param string $no  
     39     * @param string $value  
     40     * @return void 
     41     */ 
    3542    public function bindValue($no, $value) 
    3643    { 
     
    6774    { 
    6875    } 
     76 
     77    /** 
     78     * nextRowSet 
     79     * 
     80     * @return void 
     81     */ 
    6982    public function nextRowset() 
    7083    { 
    7184    } 
     85 
     86    /** 
     87     * execute() 
     88     * 
     89     * @return void 
     90     */ 
    7291    public function execute() 
    7392    { 
    7493    } 
     94 
     95    /** 
     96     * errorCode 
     97     * 
     98     * @return void 
     99     */ 
    75100    public function errorCode() 
    76101    { 
    77102    } 
     103 
     104    /** 
     105     * errorInfo 
     106     * 
     107     * @return void 
     108     */ 
    78109    public function errorInfo() 
    79110    { 
    80111    } 
     112 
     113    /** 
     114     * rowCount 
     115     * 
     116     * @return void 
     117     */ 
    81118    public function rowCount() 
    82119    { 
    83120    } 
     121 
     122    /** 
     123     * setFetchMode 
     124     * 
     125     * @param string $mode  
     126     * @return void 
     127     */ 
    84128    public function setFetchMode($mode) 
    85129    { 
    86130    } 
     131 
     132    /** 
     133     * columnCount 
     134     * 
     135     * @return void 
     136     */ 
    87137    public function columnCount() 
    88138    { 
  • branches/0.10/lib/Doctrine/Adapter/Statement/Mock.php

    r3884 r4036  
    3434class Doctrine_Adapter_Statement_Mock implements Doctrine_Adapter_Statement_Interface 
    3535{ 
    36     private $mock; 
    37      
     36    /** 
     37     * $mock 
     38     * 
     39     * @var string 
     40     */ 
     41    private $_mock; 
     42 
     43    /** 
     44     * queryString 
     45     * 
     46     * @var string 
     47     */ 
    3848    public $queryString; 
    3949 
    4050    public function __construct($mock) 
    4151    { 
    42         $this->mock  = $mock; 
     52        $this->_mock  = $mock; 
    4353    } 
    4454 
    4555    /** 
    4656     * bindColumn 
     57     * 
    4758     * Bind a column to a PHP variable 
    4859     * 
     
    6172    /** 
    6273     * bindValue 
     74     * 
    6375     * Binds a value to a corresponding named or question mark  
    6476     * placeholder in the SQL statement that was use to prepare the statement. 
     
    8092    /** 
    8193     * bindParam 
     94     * 
    8295     * Binds a PHP variable to a corresponding named or question mark placeholder in the  
    8396     * SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(), 
     
    112125    /** 
    113126     * closeCursor 
     127     * 
    114128     * Closes the cursor, enabling the statement to be executed again. 
    115129     * 
     
    123137    /**  
    124138     * columnCount 
     139     * 
    125140     * Returns the number of columns in the result set  
    126141     * 
     
    136151    /** 
    137152     * errorCode 
     153     * 
    138154     * Fetch the SQLSTATE associated with the last operation on the statement handle  
    139155     * 
     
    148164    /** 
    149165     * errorInfo 
     166     * 
    150167     * Fetch extended error information associated with the last operation on the statement handle 
    151168     * 
     
    194211    /** 
    195212     * fetchAll 
     213     * 
    196214     * Returns an array containing all of the result set rows 
    197215     * 
     
    212230    /** 
    213231     * execute 
     232     * 
    214233     * Executes a prepared statement 
    215234     * 
     
    227246    public function execute($params = null) 
    228247    { 
    229         if (is_object($this->mock)) { 
    230             $this->mock->addQuery($this->queryString); 
     248        if (is_object($this->_mock)) { 
     249            $this->_mock->addQuery($this->queryString); 
    231250        } 
    232251        return true; 
     
    235254    /** 
    236255     * fetchColumn 
     256     * 
    237257     * Returns a single column from the next row of a 
    238258     * result set or FALSE if there are no more rows. 
     
    251271    /** 
    252272     * fetchObject 
     273     * 
    253274     * Fetches the next row and returns it as an object. 
    254275     * 
     
    269290    /** 
    270291     * nextRowset 
     292     * 
    271293     * Advances to the next rowset in a multi-rowset statement handle 
    272294     *  
     
    285307    /** 
    286308     * rowCount 
     309     * 
    287310     * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement  
    288311     * executed by the corresponding object. 
     
    302325    /** 
    303326     * getColumnMeta 
     327     * 
    304328     * Returns metadata for a column in a result set 
    305329     * 
     
    318342    public function getColumnMeta($column) 
    319343    { } 
     344 
    320345    /** 
    321346     * getAttribute 
     347     * 
    322348     * Retrieve a statement attribute  
    323349     * 
     
    328354    public function getAttribute($attribute) 
    329355    { } 
     356 
    330357    /** 
    331358     * setAttribute 
     359     * 
    332360     * Set a statement attribute 
    333361     * 
     
    338366    public function setAttribute($attribute, $value) 
    339367    { } 
     368 
    340369    /** 
    341370     * setFetchMode 
     371     * 
    342372     * Set the default fetch mode for this statement 
    343373     * 
  • branches/0.10/lib/Doctrine/Connection/Profiler.php

    r3884 r4036  
    4343                                'begintransaction', 
    4444                                'exec', 
    45                                 'execute', 
    46                                 ); 
     45                                'execute'); 
    4746 
    4847    /**