Trac
- Timestamp:
- 07/04/08 17:32:19 (2 months ago)
- Files:
-
- trunk/lib/Doctrine/ClassMetadata.php (modified) (9 diffs)
- trunk/lib/Doctrine/Collection.php (modified) (17 diffs)
- trunk/lib/Doctrine/Configuration.php (modified) (1 diff)
- trunk/lib/Doctrine/Connection.php (modified) (23 diffs)
- trunk/lib/Doctrine/Connection/Mock.php (modified) (1 diff)
- trunk/lib/Doctrine/Connection/Mysql.php (modified) (2 diffs)
- trunk/lib/Doctrine/Connection/Sqlite.php (modified) (5 diffs)
- trunk/lib/Doctrine/Connection/UnitOfWork.php (modified) (8 diffs)
- trunk/lib/Doctrine/ConnectionFactory.php (modified) (2 diffs)
- trunk/lib/Doctrine/EntityManager.php (modified) (8 diffs)
- trunk/lib/Doctrine/EntityManagerFactory.php (modified) (5 diffs)
- trunk/lib/Doctrine/EntityPersister/Standard.php (modified) (1 diff)
- trunk/lib/Doctrine/EventListener.php (modified) (1 diff)
- trunk/lib/Doctrine/EventManager.php (modified) (2 diffs)
- trunk/lib/Doctrine/Exception.php (modified) (1 diff)
- trunk/lib/Doctrine/HydratorNew.php (modified) (2 diffs)
- trunk/lib/Doctrine/Manager.php (modified) (1 diff)
- trunk/lib/Doctrine/Query.php (modified) (4 diffs)
- trunk/lib/Doctrine/Query/Abstract.php (modified) (1 diff)
- trunk/lib/Doctrine/Query/Exception.php (modified) (2 diffs)
- trunk/lib/Doctrine/Sequence.php (modified) (1 diff)
- trunk/lib/Doctrine/Transaction.php (modified) (1 diff)
- trunk/tests/Orm/Query/DqlGenerationTest.php (modified) (1 diff)
- trunk/tests/Orm/UnitOfWorkTest.php (modified) (1 diff)
- trunk/tests/lib/Doctrine_TestUtil.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/Doctrine/ClassMetadata.php
r4523 r4628 142 142 143 143 /** 144 * Enter description here... 145 * 146 * @var array 147 */ 148 protected $_attributes = array('loadReferences' => true); 149 150 /** 144 151 * An array of field names. used to look up field names from column names. 145 152 * Keys are column names and values are field names. … … 149 156 */ 150 157 protected $_fieldNames = array(); 151 152 /**153 * Enter description here...154 *155 * @var unknown_type156 */157 protected $_attributes = array('loadReferences' => true);158 158 159 159 /** … … 167 167 168 168 /** 169 * Map that maps lowercased column names to field names. 170 * Mainly used during hydration because Doctrine enforces PDO_CASE_LOWER 171 * for portability. 172 * 173 * @var array 174 */ 175 protected $_lcColumnToFieldNames = array(); 176 177 /** 169 178 * Enter description here... 170 179 * 171 180 * @var unknown_type 172 181 */ 173 protected $_subclassFieldNames = array();182 //protected $_subclassFieldNames = array(); 174 183 175 184 /** … … 193 202 * @var integer 194 203 */ 195 protected $_columnCount;204 //protected $_columnCount; 196 205 197 206 /** … … 541 550 542 551 /** 543 * getFieldName 544 * 545 * returns the field name for a column name 546 * if no field name can be found the column name is returned. 552 * Gets the field name for a column name. 553 * If no field name can be found the column name is returned. 547 554 * 548 555 * @param string $columnName column name … … 556 563 557 564 /** 565 * Gets the field name for a completely lowercased column name. 566 * Mainly used during hydration. 567 * 568 * @param string $lcColumnName 569 * @return string 570 */ 571 public function getFieldNameForLowerColumnName($lcColumnName) 572 { 573 return isset($this->_lcColumnToFieldNames[$lcColumnName]) ? 574 $this->_lcColumnToFieldNames[$lcColumnName] : $lcColumnName; 575 } 576 577 public function hasLowerColumn($lcColumnName) 578 { 579 return isset($this->_lcColumnToFieldNames[$lcColumnName]); 580 } 581 582 /** 583 * Looks up the field name for a (lowercased) column name. 558 584 * 559 */ 560 public function lookupFieldName($columnName) 561 { 562 if (isset($this->_fieldNames[$columnName])) { 563 return $this->_fieldNames[$columnName]; 564 } else if (isset($this->_subclassFieldNames[$columnName])) { 565 return $this->_subclassFieldNames[$columnName]; 566 } 585 * This is mostly used during hydration, because we want to make the 586 * conversion to field names while iterating over the result set for best 587 * performance. By doing this at that point, we can avoid re-iterating over 588 * the data just to convert the column names to field names. 589 * 590 * However, when this is happening, we don't know the real 591 * class name to instantiate yet (the row data may target a sub-type), hence 592 * this method looks up the field name in the subclass mappings if it's not 593 * found on this class mapping. 594 * This lookup on subclasses is costly but happens only *once* for a column 595 * during hydration because the hydrator caches effectively. 596 */ 597 public function lookupFieldName($lcColumnName) 598 { 599 if (isset($this->_lcColumnToFieldNames[$lcColumnName])) { 600 return $this->_lcColumnToFieldNames[$lcColumnName]; 601 }/* else if (isset($this->_subclassFieldNames[$lcColumnName])) { 602 return $this->_subclassFieldNames[$lcColumnName]; 603 }*/ 567 604 568 $classMetadata = $this; 569 $conn = $this->_em; 570 571 foreach ($classMetadata->getSubclasses() as $subClass) { 572 $subClassMetadata = $conn->getClassMetadata($subClass); 573 if ($subClassMetadata->hasColumn($columnName)) { 574 $this->_subclassFieldNames[$columnName] = $subClassMetadata->getFieldName($columnName); 575 return $this->_subclassFieldNames[$columnName]; 605 foreach ($this->getSubclasses() as $subClass) { 606 $subClassMetadata = $this->_em->getClassMetadata($subClass); 607 if ($subClassMetadata->hasLowerColumn($lcColumnName)) { 608 /*$this->_subclassFieldNames[$lcColumnName] = $subClassMetadata-> 609 getFieldNameForLowerColumnName($lcColumnName); 610 return $this->_subclassFieldNames[$lcColumnName];*/ 611 return $subClassMetadata->getFieldNameForLowerColumnName($lcColumnName); 576 612 } 577 613 } 578 614 579 throw new Doctrine_ClassMetadata_Exception("No field name found for column name '$ columnName' during lookup.");615 throw new Doctrine_ClassMetadata_Exception("No field name found for column name '$lcColumnName' during lookup."); 580 616 } 581 617 … … 616 652 } 617 653 618 // extract column name & field name 654 // extract column name & field name & lowercased column name 619 655 $parts = explode(' as ', $name); 620 656 if (count($parts) > 1) { … … 623 659 $fieldName = $parts[0]; 624 660 } 625 $name = strtolower($parts[0]); 626 627 if (isset($this->_columnNames[$fieldName])) { 661 $columnName = $parts[0]; 662 $lcColumnName = strtolower($parts[0]); 663 664 if (isset($this->_mappedColumns[$columnName])) { 628 665 return; 629 666 } 630 667 668 // Fill column name <-> field name lookup maps 631 669 if ($prepend) { 632 $this->_columnNames = array_merge(array($fieldName => $ name), $this->_columnNames);633 $this->_fieldNames = array_merge(array($ name => $fieldName), $this->_fieldNames);670 $this->_columnNames = array_merge(array($fieldName => $columnName), $this->_columnNames); 671 $this->_fieldNames = array_merge(array($columnName => $fieldName), $this->_fieldNames); 634 672 } else { 635 $this->_columnNames[$fieldName] = $name; 636 $this->_fieldNames[$name] = $fieldName; 637 } 673 $this->_columnNames[$fieldName] = $columnName; 674 $this->_fieldNames[$columnName] = $fieldName; 675 } 676 $this->_lcColumnToFieldNames[$lcColumnName] = $fieldName; 677 638 678 639 679 // Inspect & fill $options … … 663 703 664 704 if ($prepend) { 665 $this->_mappedColumns = array_merge(array($ name => $options), $this->_mappedColumns);705 $this->_mappedColumns = array_merge(array($columnName => $options), $this->_mappedColumns); 666 706 } else { 667 $this->_mappedColumns[$ name] = $options;707 $this->_mappedColumns[$columnName] = $options; 668 708 } 669 709 trunk/lib/Doctrine/Collection.php
r4523 r4628 66 66 * @var Doctrine_Entity 67 67 */ 68 protected $ reference;68 protected $_owner; 69 69 70 70 /** … … 94 94 * @var Doctrine_Null 95 95 */ 96 protected static $null; 96 //protected static $null; 97 98 /** 99 * The EntityManager. 100 * 101 * @var EntityManager 102 */ 103 protected $_em; 97 104 98 105 /** … … 105 112 public function __construct($entityBaseType, $keyField = null) 106 113 { 107 if (is_string($entityBaseType)) { 108 $this->_entityBaseType = $entityBaseType; 109 $mapper = Doctrine_EntityManagerFactory::getManager($entityBaseType) 110 ->getEntityPersister($entityBaseType); 111 } 112 $this->_mapper = $mapper; 114 $this->_entityBaseType = $entityBaseType; 115 $this->_em = Doctrine_EntityManagerFactory::getManager($entityBaseType); 116 $this->_mapper = $this->_em->getEntityPersister($entityBaseType); 113 117 114 118 if ($keyField === null) { 115 $keyField = $ mapper->getClassMetadata()->getBoundQueryPart('indexBy');119 $keyField = $this->_mapper->getClassMetadata()->getBoundQueryPart('indexBy'); 116 120 } 117 121 … … 126 130 $this->_keyField = $keyField; 127 131 } 128 }129 130 /**131 * initNullObject132 * Initializes the null object for this collection.133 *134 * @return void135 */136 public static function initNullObject(Doctrine_Null $null)137 {138 self::$null = $null;139 }140 141 /**142 * getTable143 * Returns the table of the mapper of the collection.144 *145 * @return Doctrine_Table146 */147 public function getTable()148 {149 return $this->_mapper->getTable();150 }151 152 /**153 * getMapper154 * Returns the mapper of this collection.155 *156 * @return Doctrine_Mapper157 */158 public function getMapper()159 {160 return $this->_mapper;161 132 } 162 133 … … 307 278 308 279 /** 309 * setReference280 * INTERNAL: 310 281 * sets a reference pointer 311 282 * 312 283 * @return void 313 284 */ 314 public function setReference(Doctrine_Entity $ record, Doctrine_Relation $relation)315 { 316 $this-> reference = $record;285 public function setReference(Doctrine_Entity $entity, Doctrine_Relation $relation) 286 { 287 $this->_owner = $entity; 317 288 $this->relation = $relation; 318 289 … … 320 291 $relation instanceof Doctrine_Relation_LocalKey) { 321 292 $this->referenceField = $relation->getForeignFieldName(); 322 $value = $ record->get($relation->getLocalFieldName());323 foreach ($this->data as $ record) {293 $value = $entity->get($relation->getLocalFieldName()); 294 foreach ($this->data as $entity) { 324 295 if ($value !== null) { 325 $ record->set($this->referenceField, $value, false);296 $entity->set($this->referenceField, $value, false); 326 297 } else { 327 $ record->set($this->referenceField, $this->reference, false);298 $entity->set($this->referenceField, $this->_owner, false); 328 299 } 329 300 } … … 334 305 335 306 /** 307 * INTERNAL: 336 308 * getReference 337 309 * … … 340 312 public function getReference() 341 313 { 342 return $this->reference; 343 } 344 345 /** 346 * remove 347 * removes a specified collection element 314 return $this->_owner; 315 } 316 317 /** 318 * Removes an entity from the collection. 348 319 * 349 320 * @param mixed $key … … 358 329 359 330 /** 360 * contains 361 * whether or not this collection contains a specified element 331 * Checks whether the collection contains an entity. 362 332 * 363 333 * @param mixed $key the key of the element … … 379 349 380 350 /** 381 * get382 351 * returns a record for given key 383 *384 * There are two special cases:385 *386 * 1. if null is given as a key a new record is created and attached387 * at the end of the collection388 *389 * 2. if given key does not exist, then a new record is create and attached390 * to the given key391 352 * 392 353 * Collection also maps referential information to newly created records … … 397 358 public function get($key) 398 359 { 399 if ( ! isset($this->data[$key])) { 400 $record = $this->_mapper->create(); 401 402 if (isset($this->referenceField)) { 403 $value = $this->reference->get($this->relation->getLocalFieldName()); 404 405 if ($value !== null) { 406 $record->set($this->referenceField, $value, false); 407 } else { 408 $record->set($this->referenceField, $this->reference, false); 409 } 410 } 411 412 if ($key === null) { 413 $this->data[] = $record; 414 } else { 415 $this->data[$key] = $record; 416 } 417 418 if (isset($this->_keyField)) { 419 $record->set($this->_keyField, $key); 420 } 421 422 return $record; 423 } 424 425 return $this->data[$key]; 360 if (isset($this->data[$key])) { 361 return $this->data[$key]; 362 } 363 return null; 426 364 } 427 365 … … 492 430 * to adhere to the Doctrine_Access::set() signature. 493 431 */ 494 public function set($key, $ record)495 { 496 if ( ! $ record instanceOf Doctrine_Entity) {432 public function set($key, $entity) 433 { 434 if ( ! $entity instanceof Doctrine_Entity) { 497 435 throw new Doctrine_Collection_Exception('Value variable in set is not an instance of Doctrine_Entity'); 498 436 } 499 437 500 438 if (isset($this->referenceField)) { 501 $ record->set($this->referenceField, $this->reference, false);502 } 503 $this->data[$key] = $ record;439 $entity->set($this->referenceField, $this->_owner, false); 440 } 441 $this->data[$key] = $entity; 504 442 } 505 443 … … 518 456 519 457 if (isset($this->referenceField)) { 520 $value = $this-> reference->get($this->relation->getLocalFieldName());458 $value = $this->_owner->get($this->relation->getLocalFieldName()); 521 459 522 460 if ($value !== null) { 523 461 $record->set($this->referenceField, $value, false); 524 462 } else { 525 $record->set($this->referenceField, $this-> reference, false);463 $record->set($this->referenceField, $this->_owner, false); 526 464 } 527 465 } … … 560 498 561 499 /** 500 * INTERNAL: 562 501 * loadRelated 563 502 * … … 579 518 } 580 519 } 581 $query->from($this->_mapper->getComponentName() . '(' . implode(", ",$this->_mapper->getTable()->getPrimaryKeys()) . ')'); 582 $query->where($this->_mapper->getComponentName() . '.id IN (' . substr(str_repeat("?, ", count($list)),0,-2) . ')'); 520 $query->from($this->_mapper->getComponentName() 521 . '(' . implode(", ",$this->_mapper->getTable()->getPrimaryKeys()) . ')'); 522 $query->where($this->_mapper->getComponentName() 523 . '.id IN (' . substr(str_repeat("?, ", count($list)),0,-2) . ')'); 583 524 584 525 return $query; … … 608 549 609 550 /** 551 * INTERNAL: 610 552 * populateRelated 611 553 * … … 930 872 $this->data = array(); 931 873 932 if ($this-> reference) {933 $this-> reference->free($deep);934 $this-> reference= null;874 if ($this->_owner) { 875 $this->_owner->free($deep); 876 $this->_owner = null; 935 877 } 936 878 } trunk/lib/Doctrine/Configuration.php
r4523 r4628 28 28 * It combines all configuration options from DBAL & ORM. 29 29 * 30 * @author Roman Borschel <roman@code-factory.org> 30 31 * @since 2.0 31 32 */ trunk/lib/Doctrine/Connection.php
r4523 r4628 79 79 * The PDO database handle. 80 80 * 81 * @var PDO 82 * @todo Rename to $pdo. 83 */ 84 protected $dbh; 81 * @var PDO 82 */ 83 protected $_pdo; 85 84 86 85 /** … … 117 116 * @var string $driverName 118 117 */ 119 protected $ driverName;118 protected $_driverName; 120 119 121 120 /** … … 124 123 * @var boolean $isConnected 125 124 */ 126 protected $ isConnected = false;125 protected $_isConnected = false; 127 126 128 127 /** … … 164 163 * @var array $availableDrivers 165 164 */ 166 private static $ availableDrivers = array(165 private static $_availableDrivers = array( 167 166 'Mysql', 'Pgsql', 'Oracle', 'Informix', 'Mssql', 'Sqlite', 'Firebird' 168 167 ); … … 173 172 * @var integer 174 173 */ 175 protected $_ count = 0;174 protected $_queryCount = 0; 176 175 177 176 … … 221 220 * Constructor. 222 221 * 223 * @param Doctrine_Manager $manager the manager object 224 * @param PDO|Doctrine_Adapter_Interface $adapter database driver 222 * @param array $params The connection parameters. 225 223 */ 226 224 public function __construct(array $params) 227 225 { 228 226 if (isset($params['pdo'])) { 229 $this-> dbh= $params['pdo'];230 $this-> isConnected = true;227 $this->_pdo = $params['pdo']; 228 $this->_isConnected = true; 231 229 } 232 230 $this->_params = $params; … … 320 318 321 319 /** 322 * getDriverName323 *324 320 * Gets the name of the instance driver 325 321 * … … 328 324 public function getDriverName() 329 325 { 330 return $this-> driverName;326 return $this->_driverName; 331 327 } 332 328 … … 335 331 * 336 332 * @return PDO the database handler 333 * @deprecated 337 334 */ 338 335 public function getDbh() 339 336 { 340 //$this->connect(); 341 342 return $this->dbh; 337 $this->connect(); 338 return $this->_pdo; 339 } 340 341 /** 342 * Gets the PDO handle used by the connection. 343 * 344 * @return PDO 345 */ 346 public function getPdo() 347 { 348 $this->connect(); 349 return $this->_pdo; 343 350 } 344 351 … … 350 357 public function connect() 351 358 { 352 if ($this-> isConnected) {359 if ($this->_isConnected) { 353 360 return false; 354 361 } … … 357 364 //$this->getListener()->preConnect($event); 358 365 359 $e = explode(':', $this->options['dsn']);366 // TODO: the extension_loaded check can happen earlier, maybe in the factory 360 367 if (extension_loaded('pdo')) { 361 if (in_array($e[0], PDO::getAvailableDrivers())) { 362 $this->dbh = new PDO( 363 $this->options['dsn'], $this->options['username'], 364 $this->options['password'], $this->options['other']); 365 $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 366 $this->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); 367 } 368 $driverOptions = isset($this->_params['driverOptions']) ? 369 $this->_params['driverOptions'] : array(); 370 $user = isset($this->_params['user']) ? 371 $this->_params['user'] : null; 372 $password = isset($this->_params['password']) ? 373 $this->_params['password'] : null; 374 $this->_pdo = new PDO( 375 $this->_constructPdoDsn(), 376 $user, 377 $password, 378 $driverOptions 379 ); 380 $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 381 $this->_pdo->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); 368 382 } else { 369 383 throw new Doctrine_Connection_Exception("Couldn't locate driver named " . $e[0]); … … 371 385 372 386 // attach the pending attributes to adapter 373 foreach($this->pendingAttributes as $attr => $value) {387 /*foreach($this->pendingAttributes as $attr => $value) { 374 388 // some drivers don't support setting this so we just skip it 375 389 if ($attr == Doctrine::ATTR_DRIVER_NAME) { 376 390 continue; 377 391 } 378 $this-> dbh->setAttribute($attr, $value);379 } 380 381 $this-> isConnected = true;392 $this->_pdo->setAttribute($attr, $value); 393 }*/ 394 395 $this->_isConnected = true; 382 396 383 397 //$this->getListener()->postConnect($event); … … 395 409 protected function _constructPdoDsn() 396 410 { 397 411 throw Doctrine_Exception::notImplemented('_constructPdoDsn', get_class($this)); 398 412 } 399 413 … … 403 417 public function incrementQueryCount() 404 418 { 405 $this->_count++; 406 } 407 408 /** 409 * converts given driver name 410 * 411 * @param 412 */ 413 public function driverName($name) 414 {} 415 416 /** 417 * supports 419 $this->_queryCount++; 420 } 421 422 /** 423 * Checks whether a certain feature is supported. 418 424 * 419 425 * @param string $feature the name of the feature … … 666 672 public function quote($input, $type = null) 667 673 { 668 return $this-> dbh->quote($input, $type);674 return $this->_pdo->quote($input, $type); 669 675 } 670 676 … … 783 789 784 790 if ( ! $event->skipOperation) { 785 $stmt = $this-> dbh->prepare($statement);791 $stmt = $this->_pdo->prepare($statement); 786 792 } 787 793 … … 847 853 848 854 if ( ! $event->skipOperation) { 849 $stmt = $this-> dbh->query($query);850 $this->_ count++;855 $stmt = $this->_pdo->query($query); 856 $this->_queryCount++; 851 857 } 852 858 $this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event); … … 882 888 883 889 if ( ! $event->skipOperation) { 884 $count = $this-> dbh->exec($query);885 $this->_ count++;890 $count = $this->_pdo->exec($query); 891 $this->_queryCount++; 886 892 } 887 893 $this->getAttribute(Doctrine::ATTR_LISTENER)->postExec($event); … … 927 933 //$this->getListener()->preError($event); 928 934 929 $name = 'Doctrine_Connection_' . $this-> driverName . '_Exception';935 $name = 'Doctrine_Connection_' . $this->_driverName . '_Exception'; 930 936 931 937 $exc = new $name($e->getMessage(), (int) $e->getCode()); … … 950 956 public function count() 951 957 { 952 return $this->_ count;958 return $this->_queryCount; 953 959 } 954 960 … … 965 971 $this->clear(); 966 972 967 unset($this-> dbh);968 $this-> isConnected = false;973 unset($this->_pdo); 974 $this->_isConnected = false; 969 975 970 976 //$this->getAttribute(Doctrine::ATTR_LISTENER)->postClose($event); … … 991 997 $this->connect(); 992 998 993 return $this-> dbh->errorCode();999 return $this->_pdo->errorCode(); 994 1000 } 995 1001 … … 1004 1010 $this->connect(); 1005 1011 1006 return $this-> dbh->errorInfo();1012 return $this->_pdo->errorInfo(); 1007 1013 } 1008 1014 trunk/lib/Doctrine/Connection/Mock.php
r4470 r4628 39 39 * @var string $driverName the name of this connection driver 40 40 */ 41 protected $ driverName = 'MySql';41 protected $_driverName = 'Mysql'; 42 42 43 43 /** trunk/lib/Doctrine/Connection/Mysql.php
r4523 r4628 41 41 * @var string 42 42 */ 43 protected $ driverName = 'Mysql';43 protected $_driverName = 'Mysql'; 44 44 45 45 /** … … 208 208 return $this->exec($query); 209 209 } 210 211 /** 212 * Constructs the MySql PDO DSN. 213 * 214 * Overrides Connection#_constructPdoDsn(). 215 * 216 * @return string The DSN. 217 */ 218 protected function _constructPdoDsn() 219 { 220 $dsn = 'mysql:'; 221 if (isset($this->_params['host'])) { 222 $dsn .= 'host=' . $this->_params['host'] . ';'; 223 } 224 if (isset($this->_params['port'])) { 225 $dsn .= 'port=' . $this->_params['port'] . ';'; 226 } 227 if (isset($this->_params['dbname'])) { 228 $dsn .= 'dbname=' . $this->_params['dbname'] . ';'; 229 } 230 if (isset($this->_params['unix_socket'])) { 231 $dsn .= 'unix_socket=' . $this->_params['unix_socket'] . ';'; 232 } 233 234 return $dsn; 235 } 210 236 } trunk/lib/Doctrine/Connection/Sqlite.php
r4523 r4628 39 39 * @var string $driverName the name of this connection driver 40 40 */ 41 protected $ driverName = 'Sqlite';41 protected $_driverName = 'Sqlite'; 42 42 43 43 /** … … 69 69 'pattern_escaping' => false, 70 70 ); 71 71 72 parent::__construct($params); 72 73 73 if ($this-> isConnected) {74 $this-> dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2);75 $this-> dbh->sqliteCreateFunction('md5', 'md5', 1);76 $this-> dbh->sqliteCreateFunction('now', 'time', 0);74 if ($this->_isConnected) { 75 $this->_pdo->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2); 76 $this->_pdo->sqliteCreateFunction('md5', 'md5', 1); 77 $this->_pdo->sqliteCreateFunction('now', 'time', 0); 77 78 } 78 79 } … … 86 87 public function connect() 87 88 { 88 if ($this-> isConnected) {89 if ($this->_isConnected) { 89 90 return false; 90 91 } … … 92 93 parent::connect(); 93 94 94 $this-> dbh->sqliteCreateFunction('mod',array('Doctrine_Expression_Sqlite', 'modImpl'), 2);95 $this-> dbh->sqliteCreateFunction('md5', 'md5', 1);96 $this-> dbh->sqliteCreateFunction('now', 'time', 0);95 $this->_pdo->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2); 96 $this->_pdo->sqliteCreateFunction('md5', 'md5', 1); 97 $this->_pdo->sqliteCreateFunction('now', 'time', 0); 97 98 } 98 99 … … 126 127 public function dropDatabase() 127 128 { 128 try { 129 if ( ! $dsn = $this->getOption('dsn')) { 130 throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 131 } 132 133 $info = $this->getManager()->parseDsn($dsn); 129 try { 130 if ( ! $dsn = $this->getOption('dsn')) { 131 throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality'); 132 } 134 133 135 $this->export->dropDatabase($info['database']);134 $info = $this->getManager()->parseDsn($dsn); 136 135 137 return 'Successfully dropped database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; 138 } catch (Exception $e) { 139 return $e; 140 } 136 $this->export->dropDatabase($info['database']); 137 138 return 'Successfully dropped database for connection "' . $this->getName() . '" at path "' . $info['database'] . '"'; 139 } catch (Exception $e) { 140 return $e; 141 } 142 } 143 144 /** 145 * Constructs the Sqlite PDO DSN. 146 * 147 * Overrides Connection#_constructPdoDsn(). 148 * 149 * @return string The DSN. 150 */ 151 protected function _constructPdoDsn() 152 { 153 $dsn = 'sqlite:'; 154 if (isset($this->_params['path'])) { 155 $dsn .= $this->_params['path']; 156 } else if (isset($this->_params['memory'])) { 157 $dsn .= ':memory:'; 158 } 159 160 return $dsn; 141 161 } 142 162 } trunk/lib/Doctrine/Connection/UnitOfWork.php
r4523 r4628 23 23 24 24 /** 25 * The UnitOfWork is responsible for writing out changes to the database at 26 * the correct time and in the correct order. 25 * The UnitOfWork is responsible for tracking changes to objects during an 26 * "object-level" transaction and for writing out changes to the database at 27 * in the correct order. 27 28 * 28 29 * Some terminology: … … 30 31 * <b>New entity</b>: A new entity is an entity that already has an identity but 31 32 * is not yet persisted into the database. This is usually the case for all 32 * newly saved entities that use a SEQUENCE id generator. Entities with an33 * newly saved/persisted entities that use a SEQUENCE id generator. Entities with an 33 34 * IDENTITY id generator get persisted as soon as they're saved in order to 34 35 * obtain the identifier. Therefore entities that use an IDENTITY id generator 35 36 * never appear in the list of new entities of the UoW. 37 * New entities are inserted into the database when the is UnitOfWork committed. 36 38 * 37 39 * <b>Dirty entity</b>: A dirty entity is a managed entity whose values have … … 54 56 * @todo package:orm. Figure out a useful implementation. 55 57 */ 56 class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module58 class Doctrine_Connection_UnitOfWork 57 59 { 58 60 /** … … 94 96 */ 95 97 protected $_commitOrderCalculator; 98 99 /** 100 * Constructor. 101 * Created a new UnitOfWork. 102 * 103 * @param Doctrine_EntityManager $em 104 */ 105 public function __construct(Doctrine_EntityManager $em) 106 { 107 $this->_em = $em; 108 } 96 109 97 110 /** … … 202 215 203 216 /** 204 * buildFlushTree205 217 * builds a flush tree that is used in transactions 206 218 * … … 302 314 303 315 /** 304 * saveAll305 316 * persists all the pending records from all tables 306 317 * … … 309 320 * @deprecated 310 321 */ 311 public function saveAll() <322 /*public function saveAll()