Changeset 4036
- Timestamp:
- 03/19/08 05:28:31 (16 months ago)
- Location:
- branches/0.10/lib/Doctrine
- Files:
-
- 2 removed
- 8 modified
-
Adapter/Db2 (deleted)
-
Adapter/Db2.php (modified) (21 diffs)
-
Adapter/Interface.php (modified) (1 diff)
-
Adapter/Mock.php (modified) (8 diffs)
-
Adapter/Mysqli.php (modified) (7 diffs)
-
Adapter/Oracle.php (modified) (15 diffs)
-
Adapter/Resource.php (deleted)
-
Adapter/Statement.php (modified) (2 diffs)
-
Adapter/Statement/Mock.php (modified) (18 diffs)
-
Connection/Profiler.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Adapter/Db2.php
r3884 r4036 35 35 { 36 36 /** 37 * _config 38 * 37 39 * User-provided configuration. 38 40 * … … 60 62 61 63 /** 64 * _executeMode 65 * 62 66 * Execution mode 63 67 * … … 65 69 * @access protected 66 70 */ 67 protected $_execute_mode = DB2_AUTOCOMMIT_ON; 68 69 /** 71 protected $_executeMode = DB2_AUTOCOMMIT_ON; 72 73 /** 74 * _lastInsertTable 75 * 70 76 * Table name of the last accessed table for an insert operation 71 77 * This is a DB2-Adapter-specific member variable with the utmost … … 78 84 79 85 /** 80 * Constructor.86 * __construct 81 87 * 82 88 * $config is an array of key/value pairs containing configuration … … 97 103 { 98 104 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."); 100 106 } 101 107 102 108 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."); 104 110 } 105 111 106 112 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."); 108 114 } 109 115 110 116 // keep the config 111 117 $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 * 124 123 * Creates a connection resource. 125 124 * … … 134 133 135 134 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'); 137 136 } 138 137 … … 152 151 if ( ! isset($this->_config['options']['autocommit'])) { 153 152 // set execution mode 154 $this->_config['options']['autocommit'] = &$this->_execute _mode;153 $this->_config['options']['autocommit'] = &$this->_executeMode; 155 154 } 156 155 … … 182 181 // check the connection 183 182 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 * 189 190 * Force the connection to close. 190 191 * … … 198 199 199 200 /** 201 * prepare 202 * 200 203 * Returns an SQL statement for preparation. 201 204 * … … 212 215 213 216 /** 217 * _getExecuteMode 218 * 214 219 * Gets the execution mode 215 220 * … … 218 223 public function _getExecuteMode() 219 224 { 220 return $this->_execute_mode; 221 } 222 223 /** 225 return $this->_executeMode; 226 } 227 228 /** 229 * _setExecuteMode 230 * 224 231 * @param integer $mode 225 232 * @return void … … 230 237 case DB2_AUTOCOMMIT_OFF: 231 238 case DB2_AUTOCOMMIT_ON: 232 $this->_execute _mode = $mode;239 $this->_executeMode = $mode; 233 240 db2_autocommit($this->_connection, $mode); 234 241 break; 235 242 default: 236 throw new Doctrine_Adapter_ Db2_Exception("execution mode not supported");243 throw new Doctrine_Adapter_Exception("execution mode not supported"); 237 244 break; 238 245 } … … 240 247 241 248 /** 249 * _quote 250 * 242 251 * Quote a raw string. 243 252 * … … 261 270 262 271 /** 272 * getQuoteIdentifierSymbol 273 * 263 274 * @return string 264 275 */ … … 271 282 272 283 /** 284 * _beginTransaction 285 * 273 286 * Begin a transaction. 274 287 * … … 281 294 282 295 /** 296 * _commit 297 * 283 298 * Commit a transaction. 284 299 * … … 288 303 { 289 304 if ( ! db2_commit($this->_connection)) { 290 throw new Doctrine_Adapter_ Db2_Exception(305 throw new Doctrine_Adapter_Exception( 291 306 db2_conn_errormsg($this->_connection), 292 307 db2_conn_error($this->_connection)); … … 297 312 298 313 /** 314 * _rollBack 315 * 299 316 * Rollback a transaction. 300 317 * … … 304 321 { 305 322 if ( ! db2_rollback($this->_connection)) { 306 throw new Doctrine_Adapter_ Db2_Exception(323 throw new Doctrine_Adapter_Exception( 307 324 db2_conn_errormsg($this->_connection), 308 325 db2_conn_error($this->_connection)); … … 312 329 313 330 /** 331 * setFetchMode 332 * 314 333 * Set the fetch mode. 315 334 * … … 327 346 break; 328 347 default: 329 throw new Doctrine_Adapter_ Db2_Exception('Invalid fetch mode specified');348 throw new Doctrine_Adapter_Exception('Invalid fetch mode specified'); 330 349 break; 331 350 } -
branches/0.10/lib/Doctrine/Adapter/Interface.php
r3884 r4036 32 32 * @version $Revision$ 33 33 */ 34 interface Doctrine_Adapter_Interface { 34 interface Doctrine_Adapter_Interface 35 { 35 36 public function prepare($prepareString); 36 37 public function query($queryString); -
branches/0.10/lib/Doctrine/Adapter/Mock.php
r3950 r4036 22 22 /** 23 23 * Doctrine_Adapter_Mock 24 * 24 25 * This class is used for special testing purposes. 25 26 * … … 34 35 class Doctrine_Adapter_Mock implements Doctrine_Adapter_Interface, Countable 35 36 { 36 private $ name;37 private $_name; 37 38 38 private $ queries = array();39 private $_queries = array(); 39 40 40 private $ exception = array();41 private $_exception = array(); 41 42 42 private $ lastInsertIdFail = false;43 private $_lastInsertIdFail = false; 43 44 44 45 public function __construct($name = null) 45 46 { 46 $this-> name = $name;47 $this->_name = $name; 47 48 } 48 49 public function getName() 49 50 { 50 return $this-> name;51 return $this->_name; 51 52 } 52 53 public function pop() 53 54 { 54 return array_pop($this-> queries);55 return array_pop($this->_queries); 55 56 } 56 57 public function forceException($name, $message = '', $code = 0) 57 58 { 58 $this-> exception = array($name, $message, $code);59 $this->_exception = array($name, $message, $code); 59 60 } 60 61 public function prepare($query) … … 67 68 public function addQuery($query) 68 69 { 69 $this-> queries[] = $query;70 $this->_queries[] = $query; 70 71 } 71 72 public function query($query) 72 73 { 73 $this-> queries[] = $query;74 $this->_queries[] = $query; 74 75 75 $e = $this-> exception;76 $e = $this->_exception; 76 77 77 78 if ( ! empty($e)) { 78 79 $name = $e[0]; 79 80 80 $this-> exception = array();81 $this->_exception = array(); 81 82 82 83 throw new $name($e[1], $e[2]); … … 90 91 public function getAll() 91 92 { 92 return $this-> queries;93 return $this->_queries; 93 94 } 94 95 public function quote($input) … … 98 99 public function exec($statement) 99 100 { 100 $this-> queries[] = $statement;101 $this->_queries[] = $statement; 101 102 102 $e = $this-> exception;103 $e = $this->_exception; 103 104 104 105 if ( ! empty($e)) { 105 106 $name = $e[0]; 106 107 107 $this-> exception = array();108 $this->_exception = array(); 108 109 109 110 throw new $name($e[1], $e[2]); … … 115 116 { 116 117 if ($fail) { 117 $this-> lastInsertIdFail = true;118 $this->_lastInsertIdFail = true; 118 119 } else { 119 $this-> lastInsertIdFail = false;120 $this->_lastInsertIdFail = false; 120 121 } 121 122 } 122 123 public function lastInsertId() 123 124 { 124 $this-> queries[] = 'LAST_INSERT_ID()';125 if ($this-> lastInsertIdFail) {125 $this->_queries[] = 'LAST_INSERT_ID()'; 126 if ($this->_lastInsertIdFail) { 126 127 return null; 127 128 } else { … … 131 132 public function count() 132 133 { 133 return count($this-> queries);134 return count($this->_queries); 134 135 } 135 136 public function beginTransaction() 136 137 { 137 $this-> queries[] = 'BEGIN TRANSACTION';138 $this->_queries[] = 'BEGIN TRANSACTION'; 138 139 } 139 140 public function commit() 140 141 { 141 $this-> queries[] = 'COMMIT';142 $this->_queries[] = 'COMMIT'; 142 143 } 143 144 public function rollBack() 144 145 { 145 $this-> queries[] = 'ROLLBACK';146 $this->_queries[] = 'ROLLBACK'; 146 147 } 147 148 public function errorCode() … … 151 152 public function getAttribute($attribute) 152 153 { 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 } 155 157 } 156 158 public function setAttribute($attribute, $value) -
branches/0.10/lib/Doctrine/Adapter/Mysqli.php
r3884 r4036 35 35 { 36 36 /** 37 * _connect 38 * 37 39 * Creates a connection to the database. 38 40 * 39 41 * @return void 40 * @throws Doctrine_Adapter_ Mysqli_Exception42 * @throws Doctrine_Adapter_Exception 41 43 */ 42 44 protected function _connect() … … 54 56 ); 55 57 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()); 57 59 } 58 60 } 59 61 60 62 /** 63 * closeConnection 64 * 61 65 * Force the connection to close. 62 66 * … … 70 74 71 75 /** 76 * prepare 77 * 72 78 * Prepare a statement and return a PDOStatement-like object. 73 79 * … … 84 90 85 91 /** 92 * lastInsertId 93 * 86 94 * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column. 87 95 * … … 106 114 107 115 /** 116 * _beginTransaction 117 * 108 118 * Begin a transaction. 109 119 * … … 117 127 118 128 /** 129 * _commit 130 * 119 131 * Commit a transaction. 120 132 * … … 129 141 130 142 /** 143 * _rollBack 144 * 131 145 * Roll-back a transaction. 132 146 * -
branches/0.10/lib/Doctrine/Adapter/Oracle.php
r3884 r4036 35 35 { 36 36 /** 37 * _config 38 * 37 39 * User-provided configuration. 38 40 * … … 53 55 54 56 /** 57 * _executeMode 58 * 55 59 * @var integer 56 60 */ 57 protected $_execute _mode = OCI_COMMIT_ON_SUCCESS;58 59 /** 60 * Constructor.61 protected $_executeMode = OCI_COMMIT_ON_SUCCESS; 62 63 /** 64 * __construct 61 65 * 62 66 * $config is an array of key/value pairs containing configuration … … 77 81 } 78 82 79 // @todo Let this protect backward-compatibility for one release, then remove80 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 86 83 // keep the config 87 84 $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 * 100 90 * Creates a connection resource. 101 91 * 102 92 * @return void 103 * @throws Doctrine_Adapter_ Oracle_Exception93 * @throws Doctrine_Adapter_Exception 104 94 */ 105 95 protected function _connect() … … 111 101 112 102 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'); 114 104 } 115 105 … … 127 117 // check the connection 128 118 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 * 134 126 * Force the connection to close. 135 127 * … … 145 137 146 138 /** 139 * prepare 140 * 147 141 * Returns an SQL statement for preparation. 148 142 * … … 159 153 160 154 /** 155 * _quote 156 * 161 157 * Quote a raw string. 162 158 * … … 171 167 172 168 /** 169 * quoteTableAs 170 * 173 171 * Quote a table identifier and alias. 174 172 * … … 184 182 185 183 /** 184 * _beginTransaction 185 * 186 186 * Leave autocommit mode and begin a transaction. 187 187 * … … 194 194 195 195 /** 196 * _commit 197 * 196 198 * Commit a transaction and return to autocommit mode. 197 199 * 198 200 * @return void 199 * @throws Doctrine_Adapter_ Oracle_Exception201 * @throws Doctrine_Adapter_Exception 200 202 */ 201 203 protected function _commit() 202 204 { 203 205 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)); 205 207 } 206 208 $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); … … 208 210 209 211 /** 212 * _rollBack 213 * 210 214 * Roll back a transaction and return to autocommit mode. 211 215 * 212 216 * @return void 213 * @throws Doctrine_Adapter_ Oracle_Exception217 * @throws Doctrine_Adapter_Exception 214 218 */ 215 219 protected function _rollBack() 216 220 { 217 221 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)); 219 223 } 220 224 $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); … … 222 226 223 227 /** 228 * setFetchMode 229 * 224 230 * Set the fetch mode. 225 231 * … … 246 252 247 253 /** 254 * _setExecuteMode 255 * 248 256 * @param integer $mode 249 257 * @throws Doctrine_Adapter_Exception … … 255 263 case OCI_DEFAULT: 256 264 case OCI_DESCRIBE_ONLY: 257 $this->_execute _mode = $mode;265 $this->_executeMode = $mode; 258 266 break; 259 267 default: … … 264 272 265 273 /** 266 * @return 274 * _getExecuteMode 275 * 276 * @return integer $mode 267 277 */ 268 278 public function _getExecuteMode() 269 279 { 270 return $this->_execute _mode;280 return $this->_executeMode; 271 281 } 272 282 } -
branches/0.10/lib/Doctrine/Adapter/Statement.php
r3884 r4036 33 33 abstract class Doctrine_Adapter_Statement 34 34 { 35 /** 36 * bindValue 37 * 38 * @param string $no 39 * @param string $value 40 * @return void 41 */ 35 42 public function bindValue($no, $value) 36 43 { … … 67 74 { 68 75 } 76 77 /** 78 * nextRowSet 79 * 80 * @return void 81 */ 69 82 public function nextRowset() 70 83 { 71 84 } 85 86 /** 87 * execute() 88 * 89 * @return void 90 */ 72 91 public function execute() 73 92 { 74 93 } 94 95 /** 96 * errorCode 97 * 98 * @return void 99 */ 75 100 public function errorCode() 76 101 { 77 102 } 103 104 /** 105 * errorInfo 106 * 107 * @return void 108 */ 78 109 public function errorInfo() 79 110 { 80 111 } 112 113 /** 114 * rowCount 115 * 116 * @return void 117 */ 81 118 public function rowCount() 82 119 { 83 120 } 121 122 /** 123 * setFetchMode 124 * 125 * @param string $mode 126 * @return void 127 */ 84 128 public function setFetchMode($mode) 85 129 { 86 130 } 131 132 /** 133 * columnCount 134 * 135 * @return void 136 */ 87 137 public function columnCount() 88 138 { -
branches/0.10/lib/Doctrine/Adapter/Statement/Mock.php
r3884 r4036 34 34 class Doctrine_Adapter_Statement_Mock implements Doctrine_Adapter_Statement_Interface 35 35 { 36 private $mock; 37 36 /** 37 * $mock 38 * 39 * @var string 40 */ 41 private $_mock; 42 43 /** 44 * queryString 45 * 46 * @var string 47 */ 38 48 public $queryString; 39 49 40 50 public function __construct($mock) 41 51 { 42 $this-> mock = $mock;52 $this->_mock = $mock; 43 53 } 44 54 45 55 /** 46 56 * bindColumn 57 * 47 58 * Bind a column to a PHP variable 48 59 * … … 61 72 /** 62 73 * bindValue 74 * 63 75 * Binds a value to a corresponding named or question mark 64 76 * placeholder in the SQL statement that was use to prepare the statement. … … 80 92 /** 81 93 * bindParam 94 * 82 95 * Binds a PHP variable to a corresponding named or question mark placeholder in the 83 96 * SQL statement that was use to prepare the statement. Unlike Doctrine_Adapter_Statement_Interface->bindValue(), … … 112 125 /** 113 126 * closeCursor 127 * 114 128 * Closes the cursor, enabling the statement to be executed again. 115 129 * … … 123 137 /** 124 138 * columnCount 139 * 125 140 * Returns the number of columns in the result set 126 141 * … … 136 151 /** 137 152 * errorCode 153 * 138 154 * Fetch the SQLSTATE associated with the last operation on the statement handle 139 155 * … … 148 164 /** 149 165 * errorInfo 166 * 150 167 * Fetch extended error information associated with the last operation on the statement handle 151 168 * … … 194 211 /** 195 212 * fetchAll 213 * 196 214 * Returns an array containing all of the result set rows 197 215 * … … 212 230 /** 213 231 * execute 232 * 214 233 * Executes a prepared statement 215 234 * … … 227 246 public function execute($params = null) 228 247 { 229 if (is_object($this-> mock)) {230 $this-> mock->addQuery($this->queryString);248 if (is_object($this->_mock)) { 249 $this->_mock->addQuery($this->queryString); 231 250 } 232 251 return true; … … 235 254 /** 236 255 * fetchColumn 256 * 237 257 * Returns a single column from the next row of a 238 258 * result set or FALSE if there are no more rows. … … 251 271 /** 252 272 * fetchObject 273 * 253 274 * Fetches the next row and returns it as an object. 254 275 * … … 269 290 /** 270 291 * nextRowset 292 * 271 293 * Advances to the next rowset in a multi-rowset statement handle 272 294 * … … 285 307 /** 286 308 * rowCount 309 * 287 310 * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement 288 311 * executed by the corresponding object. … … 302 325 /** 303 326 * getColumnMeta 327 * 304 328 * Returns metadata for a column in a result set 305 329 * … … 318 342 public function getColumnMeta($column) 319 343 { } 344 320 345 /** 321 346 * getAttribute 347 * 322 348 * Retrieve a statement attribute 323 349 * … … 328 354 public function getAttribute($attribute) 329 355 { } 356 330 357 /** 331 358 * setAttribute 359 * 332 360 * Set a statement attribute 333 361 * … … 338 366 public function setAttribute($attribute, $value) 339 367 { } 368 340 369 /** 341 370 * setFetchMode 371 * 342 372 * Set the default fetch mode for this statement 343 373 * -
branches/0.10/lib/Doctrine/Connection/Profiler.php
r3884 r4036 43 43 'begintransaction', 44 44 'exec', 45 'execute', 46 ); 45 'execute'); 47 46 48 47 /**