Changeset 4524 for trunk/lib/Doctrine
- Timestamp:
- 06/16/08 19:31:21 (7 months ago)
- Location:
- trunk/lib/Doctrine
- Files:
-
- 10 modified
-
Entity.php (modified) (6 diffs)
-
EntityManager.php (modified) (2 diffs)
-
EntityPersister/Abstract.php (modified) (3 diffs)
-
Query/Parser.php (modified) (3 diffs)
-
Query/Production.php (modified) (3 diffs)
-
Query/Production/PathExpression.php (modified) (1 diff)
-
Query/Production/PathExpressionEndingWithAsterisk.php (modified) (1 diff)
-
Query/Production/RangeVariableDeclaration.php (modified) (2 diffs)
-
Query/Production/SelectExpression.php (modified) (1 diff)
-
Query/Production/VariableDeclaration.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/Entity.php
r4523 r4524 67 67 * An Entity is in proxy state when its properties are not fully loaded. 68 68 */ 69 const STATE_PROXY = 4;69 //const STATE_PROXY = 4; 70 70 71 71 /** … … 964 964 } 965 965 966 $class = $this->_class; 967 if ($class->hasField($fieldName)) { 968 if ($value instanceof Doctrine_Entity) { 966 if ($this->_class->hasField($fieldName)) { 967 /*if ($value instanceof Doctrine_Entity) { 969 968 $type = $class->getTypeOf($fieldName); 970 969 // FIXME: composite key support … … 974 973 $value = $id; 975 974 } 976 } 975 }*/ 977 976 978 977 $old = isset($this->_data[$fieldName]) ? $this->_data[$fieldName] : null; 979 978 980 if ($old != =$value) {979 if ($old != $value) { 981 980 $this->_data[$fieldName] = $value; 982 981 $this->_modified[] = $fieldName; 983 982 984 /* We can't do this currently because there are tests that change 985 * the primary key of already persisted entities (ugh). */ 986 if ($this->isTransient() && $class->isIdentifier($fieldName)) { 983 if ($this->isTransient() && $this->_class->isIdentifier($fieldName)) { 987 984 $this->_id[$fieldName] = $value; 988 985 } … … 997 994 } 998 995 } 999 } else if ($ class->hasRelation($fieldName)) {996 } else if ($this->_class->hasRelation($fieldName)) { 1000 997 $this->_rawSetReference($fieldName, $value); 1001 998 } else { … … 1142 1139 break; 1143 1140 default: 1144 if ($this->_data[$field] instanceof Doctrine_Entity) {1141 /*if ($this->_data[$field] instanceof Doctrine_Entity) { 1145 1142 // FIXME: composite key support 1146 1143 $ids = $this->_data[$field]->identifier(); 1147 1144 $id = count($ids) > 0 ? array_pop($ids) : null; 1148 1145 $this->_data[$field] = $id; 1149 } 1146 }*/ 1150 1147 /** TODO: 1151 1148 if ($this->_data[$v] === null) { … … 1160 1157 // @todo cleanup 1161 1158 // populates the discriminator field in Single & Class Table Inheritance 1162 $class = $this->_class; 1163 if ($class->getInheritanceType() == Doctrine::INHERITANCE_TYPE_JOINED || 1164 $class->getInheritanceType() == Doctrine::INHERITANCE_TYPE_SINGLE_TABLE) { 1165 $discCol = $class->getInheritanceOption('discriminatorColumn'); 1166 $discMap = $class->getInheritanceOption('discriminatorMap'); 1159 if ($this->_class->getInheritanceType() == Doctrine::INHERITANCE_TYPE_JOINED || 1160 $this->_class->getInheritanceType() == Doctrine::INHERITANCE_TYPE_SINGLE_TABLE) { 1161 $discCol = $this->_class->getInheritanceOption('discriminatorColumn'); 1162 $discMap = $this->_class->getInheritanceOption('discriminatorMap'); 1167 1163 $old = $this->get($discCol, false); 1168 1164 $discValue = array_search($this->_entityName, $discMap); -
trunk/lib/Doctrine/EntityManager.php
r4523 r4524 60 60 private $_config; 61 61 62 63 62 /** 64 63 * The database connection used by the EntityManager. … … 410 409 public function save(Doctrine_Entity $entity) 411 410 { 411 $state = $entity->_state(); 412 if ($state == Doctrine_Entity::STATE_CLEAN || $state == Doctrine_Entity::STATE_LOCKED) { 413 return; 414 } 415 412 416 //... 417 //$this->_unitOfWork-> 418 switch ($entity->_state()) { 419 case Doctrine_Entity::STATE_CLEAN: 420 //nothing to do 421 break; 422 case Doctrine_Entity::STATE_DIRTY: 423 $this->_unitOfWork->registerDirty($entity); 424 break; 425 case Doctrine_Entity::STATE_TCLEAN: 426 case Doctrine_Entity::STATE_TDIRTY: 427 //... 428 } 413 429 } 414 430 -
trunk/lib/Doctrine/EntityPersister/Abstract.php
r4523 r4524 249 249 250 250 /** 251 * Saves an entity and all it's related entities.251 * Saves an entity. 252 252 * 253 253 * @param Doctrine_Entity $record The entity to save. 254 254 * @param Doctrine_Connection $conn The connection to use. Will default to the mapper's 255 255 * connection. 256 * @throws Doctrine_Mapper_Exception If the mapper is unable to save the given entity. 257 */ 258 public function save(Doctrine_Entity $record, Doctrine_Connection $conn = null) 256 */ 257 public function save(Doctrine_Entity $record) 259 258 { 260 259 if ( ! ($record instanceof $this->_domainClassName)) { … … 283 282 $this->_insertOrUpdate($record); 284 283 } else { 285 $conn-> transaction->addInvalid($record);284 $conn->getTransaction()->addInvalid($record); 286 285 } 287 286 … … 376 375 // Protection against infinite function recursion before attempting to save 377 376 if ($obj instanceof Doctrine_Entity && $obj->isModified()) { 378 $obj->save( $this->_conn);377 $obj->save(); 379 378 380 379 /** Can this be removed? -
trunk/lib/Doctrine/Query/Parser.php
r4523 r4524 102 102 */ 103 103 protected $_errorDistance; 104 105 /** 106 * The EntityManager. 107 * 108 * @var EnityManager 109 */ 110 protected $_em; 104 111 105 112 // End of Error management stuff … … 114 121 public function __construct(Doctrine_Query $query) 115 122 { 123 $this->_em = $query->getEntityManager(); 116 124 $this->_scanner = new Doctrine_Query_Scanner($query->getDql()); 117 $this->_sqlBuilder = Doctrine_Query_SqlBuilder::fromConnection($ query->getEntityManager());125 $this->_sqlBuilder = Doctrine_Query_SqlBuilder::fromConnection($this->_em); 118 126 $this->_keywordTable = new Doctrine_Query_Token(); 119 127 … … 334 342 $this->_errorDistance = 0; 335 343 } 336 344 345 /** 346 * Gets the EntityManager used by the parser. 347 * 348 * @return EntityManager 349 */ 350 public function getEntityManager() 351 { 352 return $this->_em; 353 } 337 354 } -
trunk/lib/Doctrine/Query/Production.php
r4523 r4524 1 1 <?php 2 3 2 /* 4 3 * $Id$ … … 54 53 */ 55 54 protected $_parser; 55 56 /** 57 * The EntityManager. 58 * 59 * @var EntityManager 60 */ 61 protected $_em; 56 62 57 63 … … 64 70 { 65 71 $this->_parser = $parser; 72 $this->_em = $this->_parser->getEntityManager(); 66 73 } 67 74 -
trunk/lib/Doctrine/Query/Production/PathExpression.php
r4523 r4524 131 131 132 132 // Retrieving connection 133 $manager = Doctrine_EntityManagerFactory::getManager(); 134 $conn = $manager->getConnection(); 133 $conn = $this->_em->getConnection(); 135 134 136 135 // Looking for queryComponent to fetch -
trunk/lib/Doctrine/Query/Production/PathExpressionEndingWithAsterisk.php
r4523 r4524 120 120 121 121 // Retrieving connection 122 $manager = Doctrine_EntityManagerFactory::getManager(); 123 $conn = $manager->getConnection(); 122 $conn = $this->_em->getConnection(); 124 123 125 124 // Looking for componentAlias to fetch -
trunk/lib/Doctrine/Query/Production/RangeVariableDeclaration.php
r4523 r4524 116 116 117 117 // Get the connection for the component 118 $conn = $this->_parser->getSqlBuilder()->getConnection(); 119 $manager = Doctrine_EntityManagerFactory::getManager(); 118 $conn = $this->_em->getConnection(); 120 119 $componentName = $this->_identifiers[0]; 121 120 122 121 // Retrieving ClassMetadata and Mapper 123 122 try { 124 $classMetadata = $ manager->getClassMetadata($componentName);123 $classMetadata = $this->_em->getClassMetadata($componentName); 125 124 126 125 // Building queryComponent … … 156 155 157 156 // Get the connection for the component 158 $conn = $this->_parser->getSqlBuilder()->getConnection(); 159 $manager = Doctrine_EntityManagerFactory::getManager(); 157 $conn = $this->_em->getConnection(); 160 158 161 159 // Retrieve the base component -
trunk/lib/Doctrine/Query/Production/SelectExpression.php
r4523 r4524 137 137 138 138 // Retrieving connection 139 $manager = Doctrine_EntityManagerFactory::getManager(); 140 $conn = $manager->getConnection(); 139 $conn = $this->_em->getConnection(); 141 140 142 141 switch (get_class($this->_leftExpression)) { -
trunk/lib/Doctrine/Query/Production/VariableDeclaration.php
r4523 r4524 84 84 85 85 // Get the connection for the component 86 $conn = $this->_parser->getSqlBuilder()->getConnection(); 87 $manager = Doctrine_EntityManagerFactory::getManager(); 86 $conn = $this->_em->getConnection(); 88 87 89 88 // Retrieving ClassMetadata and Mapper 90 89 try { 91 $classMetadata = $ manager->getMetadata($this->_componentName);90 $classMetadata = $this->_em->getMetadata($this->_componentName); 92 91 93 92 // Building queryComponent … … 125 124 126 125 // Retrieving connection 127 $manager = Doctrine_EntityManagerFactory::getManager(); 128 $conn = $manager->getConnection(); 126 $conn = $this->_em->getConnection(); 129 127 130 128 return $conn->quoteIdentifier($queryComponent['metadata']->getTableName()) . ' '