Changeset 4789 for trunk/lib/Doctrine
- Timestamp:
- 08/22/08 10:05:14 (5 months ago)
- Location:
- trunk/lib/Doctrine
- Files:
-
- 44 modified
-
Association.php (modified) (1 diff)
-
Association/OneToMany.php (modified) (1 diff)
-
Cache/Apc.php (modified) (1 diff)
-
Cache/Memcache.php (modified) (2 diffs)
-
Cache/Xcache.php (modified) (1 diff)
-
ClassMetadata.php (modified) (15 diffs)
-
ClassMetadata/Factory.php (modified) (4 diffs)
-
Collection.php (modified) (9 diffs)
-
Connection.php (modified) (1 diff)
-
Connection/UnitOfWork.php (modified) (2 diffs)
-
DatabasePlatform/MySqlPlatform.php (modified) (1 diff)
-
DataDict/Informix.php (modified) (1 diff)
-
Entity.php (modified) (17 diffs)
-
EntityManager.php (modified) (3 diffs)
-
EntityPersister/Abstract.php (modified) (11 diffs)
-
EntityPersister/JoinedSubclass.php (modified) (3 diffs)
-
Hook/Equal.php (modified) (2 diffs)
-
Hook/Integer.php (modified) (2 diffs)
-
Hook/Parser.php (modified) (1 diff)
-
Hook/Parser/Complex.php (modified) (2 diffs)
-
Hook/WordLike.php (modified) (2 diffs)
-
Query/Production/Join.php (modified) (1 diff)
-
Query/Production/JoinVariableDeclaration.php (modified) (1 diff)
-
RawSql/Exception.php (modified) (2 diffs)
-
Record/Exception.php (modified) (2 diffs)
-
Record/Filter.php (modified) (1 diff)
-
Record/Filter/Compound.php (modified) (1 diff)
-
Record/Filter/Standard.php (modified) (1 diff)
-
Record/Generator.php (modified) (1 diff)
-
Record/Iterator.php (modified) (1 diff)
-
Record/Listener.php (modified) (1 diff)
-
Record/Listener/Chain.php (modified) (2 diffs)
-
Record/Listener/Interface.php (modified) (1 diff)
-
Record/State/Exception.php (modified) (2 diffs)
-
Relation.php (modified) (1 diff)
-
Relation/Association.php (modified) (2 diffs)
-
Relation/Association/Self.php (modified) (1 diff)
-
Relation/ForeignKey.php (modified) (1 diff)
-
Relation/LocalKey.php (modified) (1 diff)
-
Relation/Nest.php (modified) (2 diffs)
-
Relation/Parser.php (modified) (1 diff)
-
Relation/Parser/Exception.php (modified) (2 diffs)
-
Sequence/Mysql.php (modified) (1 diff)
-
Sequence/Sqlite.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/Association.php
r4776 r4789 160 160 $this->_customMutator = isset($mapping['mutator']) ? $mapping['mutator'] : null; 161 161 $this->_isOptional = isset($mapping['isOptional']) ? (bool)$mapping['isOptional'] : true; 162 $this->_cascades = isset($mapping['cascade']) ? (array)$mapping['cascade'] : array(); 162 163 163 164 return $mapping; -
trunk/lib/Doctrine/Association/OneToMany.php
r4718 r4789 1 1 <?php 2 /* 3 * $Id$ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information, see 19 * <http://www.phpdoctrine.org>. 20 */ 2 21 3 22 #namespace Doctrine::ORM::Mappings; 4 23 24 /** 25 * Represents a one-to-many mapping. 26 * 27 * NOTE: One-to-many mappings can currently not be uni-directional (one -> many). 28 * They must either be bidirectional (one <-> many) or unidirectional (many -> one). 29 * In other words, the many-side MUST be the owning side and the one-side MUST be 30 * the inverse side. 31 * 32 * @author Roman Borschel <roman@code-factory.org> 33 * @since 2.0 34 * @todo Rename to OneToManyMapping 35 */ 5 36 class Doctrine_Association_OneToMany extends Doctrine_Association 6 37 { 7 38 /** The target foreign key columns that reference the sourceKeyColumns. */ 8 protected $_targetForeignKeyColumns; 39 /* NOTE: Currently not used because uni-directional one-many not supported atm. */ 40 //protected $_targetForeignKeyColumns; 9 41 10 42 /** The (typically primary) source key columns that are referenced by the targetForeignKeyColumns. */ 11 protected $_sourceKeyColumns; 43 /* NOTE: Currently not used because uni-directional one-many not supported atm. */ 44 //protected $_sourceKeyColumns; 12 45 13 46 /** This maps the target foreign key columns to the corresponding (primary) source key columns. */ 14 protected $_targetForeignKeysToSourceKeys; 47 /* NOTE: Currently not used because uni-directional one-many not supported atm. */ 48 //protected $_targetForeignKeysToSourceKeys; 15 49 16 50 /** This maps the (primary) source key columns to the corresponding target foreign key columns. */ 17 protected $_sourceKeysToTargetForeignKeys; 51 /* NOTE: Currently not used because uni-directional one-many not supported atm. */ 52 //protected $_sourceKeysToTargetForeignKeys; 18 53 19 54 /** Whether to delete orphaned elements (removed from the collection) */ 20 55 protected $_deleteOrphans = false; 21 56 57 /** 58 * Constructor. 59 * Creates a new OneToManyMapping. 60 * 61 * @param array $mapping The mapping info. 62 */ 63 public function __construct(array $mapping) 64 { 65 parent::__construct($mapping); 66 // one side in one-many can currently never be owning side, we may support that later 67 $this->_isOwningSide = false; 68 } 69 70 /** 71 * Whether orphaned elements (removed from the collection) should be deleted. 72 * 73 * @return boolean TRUE if orphaned elements should be deleted, FALSE otherwise. 74 */ 22 75 public function shouldDeleteOrphans() 23 76 { 24 77 return $this->_deleteOrphans; 25 78 } 79 80 /** 81 * Whether the association is one-to-many. 82 * 83 * @return boolean TRUE if the association is one-to-many, FALSE otherwise. 84 * @override 85 */ 86 public function isOneToMany() 87 { 88 return true; 89 } 90 91 26 92 } 27 93 -
trunk/lib/Doctrine/Cache/Apc.php
r4723 r4789 84 84 public function save($id, $data, $lifeTime = false) 85 85 { 86 $lifeTime = $this->getLifeTime($lifeTime); 87 88 return (bool) apc_store($id, array($data, time()), $lifeTime); 86 return (bool) apc_store($id, $data, $lifeTime); 89 87 } 90 88 -
trunk/lib/Doctrine/Cache/Memcache.php
r3931 r4789 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 Doctrine::autoload('Doctrine_Cache_Driver'); 21 22 22 /** 23 23 * Doctrine_Cache_Memcache … … 81 81 public function fetch($id, $testCacheValidity = true) 82 82 { 83 $tmp = $this->_memcache->get($id); 84 85 if (is_array($tmp)) { 86 return $tmp[0]; 87 } else if (is_string($tmp)) { 88 return $tmp; 89 } 90 91 return false; 83 return $this->_memcache->get($id); 92 84 } 93 85 -
trunk/lib/Doctrine/Cache/Xcache.php
r3931 r4789 19 19 * <http://www.phpdoctrine.org>. 20 20 */ 21 Doctrine::autoload('Doctrine_Cache_Driver'); 21 22 22 /** 23 23 * Doctrine_Cache_Xcache -
trunk/lib/Doctrine/ClassMetadata.php
r4776 r4789 26 26 /** 27 27 * A <tt>ClassMetadata</tt> instance holds all the information (metadata) of an entity and 28 * it's associations and how they're mapped to therelational database.28 * it's associations and how they're mapped to a relational database. 29 29 * It is the backbone of Doctrine's metadata mapping. 30 30 * 31 31 * @author Roman Borschel <roman@code-factory.org> 32 32 * @since 2.0 33 * @todo Rename to ClassDescriptor ?33 * @todo Rename to ClassDescriptor. 34 34 */ 35 35 class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable 36 36 { 37 37 /* The inheritance mapping types */ 38 /** 39 * NONE means the class does not participate in an inheritance hierarchy 40 * and therefore does not need an inheritance mapping type. 41 */ 38 42 const INHERITANCE_TYPE_NONE = 'none'; 43 /** 44 * JOINED means the class will be persisted according to the rules of 45 * <tt>Class Table Inheritance</tt>. 46 */ 39 47 const INHERITANCE_TYPE_JOINED = 'joined'; 48 /** 49 * SINGLE_TABLE means the class will be persisted according to the rules of 50 * <tt>Single Table Inheritance</tt>. 51 */ 40 52 const INHERITANCE_TYPE_SINGLE_TABLE = 'singleTable'; 53 /** 54 * TABLE_PER_CLASS means the class will be persisted according to the rules 55 * of <tt>Concrete Table Inheritance</tt>. 56 */ 41 57 const INHERITANCE_TYPE_TABLE_PER_CLASS = 'tablePerClass'; 42 58 43 /* The Id generator types. TODO: belongs more in a DBAL class */ 59 /* The Id generator types. */ 60 /** 61 * AUTO means the generator type will depend on what the used platform prefers. 62 * Offers full portability. 63 */ 44 64 const GENERATOR_TYPE_AUTO = 'auto'; 65 /** 66 * SEQUENCE means a separate sequence object will be used. Platforms that do 67 * not have native sequence support may emulate it. Full portability is currently 68 * not guaranteed. 69 */ 45 70 const GENERATOR_TYPE_SEQUENCE = 'sequence'; 71 /** 72 * TABLE means a separate table is used for id generation. 73 * Offers full portability. 74 */ 46 75 const GENERATOR_TYPE_TABLE = 'table'; 76 /** 77 * IDENTITY means an identity column is used for id generation. The database 78 * will fill in the id column on insertion. Platforms that do not support 79 * native identity columns may emulate them. Full portability is currently 80 * not guaranteed. 81 */ 47 82 const GENERATOR_TYPE_IDENTITY = 'identity'; 83 /** 84 * NONE means the class does not have a generated id. That means the class 85 * must have a natural id. 86 */ 48 87 const GENERATOR_TYPE_NONE = 'none'; 49 88 … … 54 93 const ENTITY_TYPE_REGULAR = 'regular'; 55 94 /** 56 * A transient entity is ignored by Doctrine .95 * A transient entity is ignored by Doctrine (so ... it's not an entity really). 57 96 */ 58 97 const ENTITY_TYPE_TRANSIENT = 'transient'; … … 216 255 */ 217 256 protected $_lcColumnToFieldNames = array(); 218 219 /**220 * Relation parser object. Manages the relations for the class.221 *222 * @var Doctrine_Relation_Parser $_parser223 * @todo Remove.224 */225 protected $_parser;226 257 227 258 /** … … 316 347 $this->_rootEntityName = $entityName; 317 348 $this->_em = $em; 318 319 $this->_parser = new Doctrine_Relation_Parser($this);320 349 } 321 350 … … 504 533 } 505 534 535 public function addFieldMapping($fieldName, array $mapping) 536 { 537 $this->_fieldMappings[$fieldName] = $mapping; 538 } 539 506 540 /** 507 541 * Gets the mapping of an association. … … 518 552 519 553 return $this->_associationMappings[$fieldName]; 554 } 555 556 public function addAssociationMapping($fieldName, Doctrine_Association $assoc) 557 { 558 $this->_associationMappings[$fieldName] = $assoc; 520 559 } 521 560 … … 880 919 } 881 920 921 public function isInheritanceTypeJoined() 922 { 923 return $this->_inheritanceType == self::INHERITANCE_TYPE_JOINED; 924 } 925 926 public function isInheritanceTypeSingleTable() 927 { 928 return $this->_inheritanceType == self::INHERITANCE_TYPE_SINGLE_TABLE; 929 } 930 931 public function isInheritanceTypeTablePerClass() 932 { 933 return $this->_inheritanceType == self::INHERITANCE_TYPE_TABLE_PER_CLASS; 934 } 935 882 936 /** 883 937 * Checks whether the class uses an identity column for the Id generation. … … 1008 1062 { 1009 1063 return $this->_subClasses; 1064 } 1065 1066 /** 1067 * Gets the name of the class in the entity hierarchy that owns the field with 1068 * the given name. The owning class is the one that defines the field. 1069 * 1070 * @param string $fieldName 1071 * @return string 1072 * @todo Consider using 'inherited' => 'ClassName' to make the lookup simpler. 1073 */ 1074 public function getOwningClass($fieldName) 1075 { 1076 if ($this->_inheritanceType == self::INHERITANCE_TYPE_NONE) { 1077 return $this; 1078 } else { 1079 foreach ($this->_parentClasses as $parentClass) { 1080 if ( ! $this->_em->getClassMetadata($parentClass)->isInheritedField($fieldName)) { 1081 return $parentClass; 1082 } 1083 } 1084 } 1085 1086 throw new Doctrine_ClassMetadata_Exception("Unable to find defining class of field '$fieldName'."); 1010 1087 } 1011 1088 … … 1409 1486 1410 1487 /** 1411 * Adds a one-to-one associationmapping.1412 * 1413 * @ todo Implementation.1488 * Adds a one-to-one mapping. 1489 * 1490 * @param array $mapping The mapping. 1414 1491 */ 1415 1492 public function mapOneToOne(array $mapping) … … 1426 1503 1427 1504 /** 1428 * @todo Implementation. 1505 * Adds a one-to-many mapping. 1506 * 1507 * @param array $mapping The mapping. 1429 1508 */ 1430 1509 public function mapOneToMany(array $mapping) … … 1441 1520 1442 1521 /** 1443 * @todo Implementation. 1522 * Adds a many-to-one mapping. 1523 * 1524 * @param array $mapping The mapping. 1444 1525 */ 1445 1526 public function mapManyToOne(array $mapping) 1446 1527 { 1447 1528 // A many-to-one mapping is simply a one-one backreference 1529 $this->mapOneToOne($mapping); 1448 1530 } 1449 1531 … … 1586 1668 * Completes the identifier mapping of the class. 1587 1669 * NOTE: Should only be called by the ClassMetadataFactory! 1670 * 1671 * @return void 1588 1672 */ 1589 1673 public function completeIdentifierMapping() … … 1604 1688 * @todo Implementation. Immutable entities can not be updated or deleted once 1605 1689 * they are created. This means the entity can only be modified as long as it's 1606 * in transient state (TCLEAN, TDIRTY).1690 * new (STATE_NEW). 1607 1691 */ 1608 1692 public function isImmutable() … … 1635 1719 } 1636 1720 1637 /* The following stuff needs to be touched for the association mapping rewrite */1638 1639 /**1640 * hasOne1641 * binds One-to-One aggregate relation1642 *1643 * @param string $componentName the name of the related component1644 * @param string $options relation options1645 * @see Doctrine_Relation::_$definition1646 * @return Doctrine_Entity this object1647 * @deprecated1648 */1649 public function hasOne()1650 {1651 $this->bind(func_get_args(), Doctrine_Relation::ONE_AGGREGATE);1652 1653 return $this;1654 }1655 1656 /**1657 * hasMany1658 * binds One-to-Many / Many-to-Many aggregate relation1659 *1660 * @param string $componentName the name of the related component1661 * @param string $options relation options1662 * @see Doctrine_Relation::_$definition1663 * @return Doctrine_Entity this object1664 * @deprecated1665 */1666 public function hasMany()1667 {1668 $this->bind(func_get_args(), Doctrine_Relation::MANY_AGGREGATE);1669 1670 return $this;1671 }1672 1673 /**1674 * @deprecated1675 */1676 public function bindRelation($args, $type)1677 {1678 return $this->bind($args, $type);1679 }1680 1681 /**1682 * @todo Relation mapping rewrite.1683 * @deprecated1684 */1685 public function bind($args, $type)1686 {1687 $options = array();1688 $options['type'] = $type;1689 1690 if ( ! isset($args[1])) {1691 $args[1] = array();1692 }1693 if ( ! is_array($args[1])) {1694 try {1695 throw new Exception();1696 } catch (Exception $e) {1697 echo $e->getTraceAsString();1698 }1699 }1700 $options = array_merge($args[1], $options);1701 $this->_parser->bind($args[0], $options);1702 }1703 1704 /**1705 * hasRelation1706 *1707 * @param string $alias the relation to check if exists1708 * @return boolean true if the relation exists otherwise false1709 * @deprecated1710 */1711 public function hasRelation($alias)1712 {1713 return $this->_parser->hasRelation($alias);1714 }1715 1716 1721 public function hasAssociation($fieldName) 1717 1722 { … … 1720 1725 1721 1726 /** 1722 * getRelation1723 *1724 * @param string $alias relation alias1725 * @deprecated1726 */1727 public function getRelation($alias, $recursive = true)1728 {1729 return $this->_parser->getRelation($alias, $recursive);1730 }1731 1732 /**1733 * @deprecated1734 */1735 public function getRelationParser()1736 {1737 return $this->_parser;1738 }1739 1740 /**1741 * getRelations1742 * returns an array containing all relation objects1743 *1744 * @return array an array of Doctrine_Relation objects1745 * @deprecated1746 */1747 public function getRelations()1748 {1749 return $this->_parser->getRelations();1750 }1751 1752 /**1753 1727 * 1754 1728 */ -
trunk/lib/Doctrine/ClassMetadata/Factory.php
r4776 r4789 32 32 * @link www.phpdoctrine.org 33 33 * @since 2.0 34 * @todo Rename to Class MetadataFactory.34 * @todo Rename to ClassDescriptorFactory. 35 35 */ 36 36 class Doctrine_ClassMetadata_Factory … … 115 115 // -> child1 -> child2 -> $name 116 116 117 // Move down the hierarchy of parent classes, starting from the topmost class 117 118 $parent = $class; 118 119 foreach ($parentClasses as $subclassName) { … … 122 123 $this->_addInheritedRelations($subClass, $parent); 123 124 $this->_loadMetadata($subClass, $subclassName); 124 if ($parent-> getInheritanceType() == Doctrine::INHERITANCE_TYPE_SINGLE_TABLE) {125 if ($parent->isInheritanceTypeSingleTable()) { 125 126 $subClass->setTableName($parent->getTableName()); 126 127 } … … 133 134 * Adds inherited fields to the subclass mapping. 134 135 * 136 * @param Doctrine::ORM::Mapping::ClassMetadata $subClass 137 * @param Doctrine::ORM::Mapping::ClassMetadata $parentClass 138 * @return void 139 */ 140 protected function _addInheritedFields($subClass, $parentClass) 141 { 142 foreach ($parentClass->getFieldMappings() as $fieldName => $mapping) { 143 if ( ! isset($mapping['inherited'])) { 144 $mapping['inherited'] = $parentClass->getClassName(); 145 } 146 $subClass->addFieldMapping($fieldName, $mapping); 147 } 148 } 149 150 /** 151 * Adds inherited associations to the subclass mapping. 152 * 135 153 * @param unknown_type $subClass 136 154 * @param unknown_type $parentClass 137 155 */ 138 protected function _addInheritedFields($subClass, $parentClass)139 {140 foreach ($parentClass->getFieldMappings() as $fieldName => $mapping) {141 $fullName = "$name as " . $parentClass->getFieldName($name);142 $mapping['inherited'] = true;143 $subClass->mapField($mapping);144 }145 }146 147 /**148 * Adds inherited associations to the subclass mapping.149 *150 * @param unknown_type $subClass151 * @param unknown_type $parentClass152 */153 156 protected function _addInheritedRelations($subClass, $parentClass) 154 157 { 155 foreach ($parentClass->get RelationParser()->getRelationDefinitions() as $name => $definition) {156 $subClass-> getRelationParser()->addRelationDefinition($name, $definition);158 foreach ($parentClass->getAssociationMappings() as $fieldName => $mapping) { 159 $subClass->addAssociationMapping($name, $mapping); 157 160 } 158 161 } -
trunk/lib/Doctrine/Collection.php
r4776 r4789 84 84 * @var Doctrine::ORM::Mapping::AssociationMapping 85 85 */ 86 protected $_association Mapping;86 protected $_association; 87 87 88 88 /** … … 99 99 */ 100 100 //protected static $null; 101 102 protected $_mapping;103 101 104 102 /** … … 262 260 * @return void 263 261 */ 264 public function setReference(Doctrine_Entity $entity, $relation)262 public function setReference(Doctrine_Entity $entity, Doctrine_Association $relation) 265 263 { 266 264 $this->_owner = $entity; 267 //$this->relation= $relation;265 $this->_association = $relation; 268 266 269 267 /*if