Changeset 4718 for trunk/lib/Doctrine
- Timestamp:
- 07/27/08 20:38:56 (6 months ago)
- Location:
- trunk/lib/Doctrine
- Files:
-
- 32 modified
-
Access.php (modified) (1 diff)
-
Association/ManyToMany.php (modified) (1 diff)
-
Association/OneToMany.php (modified) (1 diff)
-
Association/OneToOne.php (modified) (1 diff)
-
ClassMetadata.php (modified) (7 diffs)
-
Compiler.php (modified) (1 diff)
-
Configuration.php (modified) (3 diffs)
-
Connection.php (modified) (42 diffs)
-
Connection/Mssql.php (modified) (1 diff)
-
Connection/UnitOfWork.php (modified) (3 diffs)
-
DataDict.php (modified) (1 diff)
-
DataDict/Firebird.php (modified) (2 diffs)
-
DataDict/Informix.php (modified) (1 diff)
-
DataDict/Mysql.php (modified) (1 diff)
-
DataDict/Oracle.php (modified) (1 diff)
-
Entity.php (modified) (32 diffs)
-
EntityManager.php (modified) (3 diffs)
-
EntityPersister/Abstract.php (modified) (8 diffs)
-
Export.php (modified) (1 diff)
-
Export/Oracle.php (modified) (1 diff)
-
Expression.php (modified) (1 diff)
-
Expression/Driver.php (modified) (1 diff)
-
Formatter.php (modified) (1 diff)
-
Hydrator/Abstract.php (modified) (8 diffs)
-
Hydrator/ArrayDriver.php (modified) (3 diffs)
-
Hydrator/RecordDriver.php (modified) (2 diffs)
-
HydratorNew.php (modified) (6 diffs)
-
Internal/CommitOrderCalculator.php (modified) (1 diff)
-
Internal/CommitOrderNode.php (modified) (2 diffs)
-
Sequence.php (modified) (1 diff)
-
Sequence/Mysql.php (modified) (1 diff)
-
Transaction/Mssql.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/Access.php
r4456 r4718 35 35 * @version $Revision$ 36 36 * @author Konsta Vesterinen <kvesteri@cc.hut.fi> 37 * @todo Consider making Collection & Entity implement ArrayAccess directly. 38 * This base class is not really a huge benefit. 37 39 */ 38 40 abstract class Doctrine_Access implements ArrayAccess -
trunk/lib/Doctrine/Association/ManyToMany.php
r4699 r4718 34 34 35 35 /** The field in the source table that corresponds to the key in the relation table */ 36 protected $_sourceKey Fields;36 protected $_sourceKeyColumns; 37 37 38 38 /** The field in the target table that corresponds to the key in the relation table */ 39 protected $_targetKey Fields;39 protected $_targetKeyColumns; 40 40 41 41 /** The field in the intermediate table that corresponds to the key in the source table */ 42 protected $_sourceRelationKey Fields;42 protected $_sourceRelationKeyColumns; 43 43 44 44 /** The field in the intermediate table that corresponds to the key in the target table */ 45 protected $_targetRelationKey Fields;45 protected $_targetRelationKeyColumns; 46 46 47 47 -
trunk/lib/Doctrine/Association/OneToMany.php
r4699 r4718 5 5 class Doctrine_Association_OneToMany extends Doctrine_Association 6 6 { 7 /** The target foreign key fields that reference the sourceKeyFields. */8 protected $_targetForeignKey Fields;7 /** The target foreign key columns that reference the sourceKeyColumns. */ 8 protected $_targetForeignKeyColumns; 9 9 10 /** The (typically primary) source key fields that are referenced by the targetForeignKeyFields. */11 protected $_sourceKey Fields;10 /** The (typically primary) source key columns that are referenced by the targetForeignKeyColumns. */ 11 protected $_sourceKeyColumns; 12 12 13 /** This maps the target foreign key fields to the corresponding (primary) source key fields. */13 /** This maps the target foreign key columns to the corresponding (primary) source key columns. */ 14 14 protected $_targetForeignKeysToSourceKeys; 15 15 16 /** This maps the (primary) source key fields to the corresponding target foreign key fields. */16 /** This maps the (primary) source key columns to the corresponding target foreign key columns. */ 17 17 protected $_sourceKeysToTargetForeignKeys; 18 18 19 19 /** Whether to delete orphaned elements (removed from the collection) */ 20 protected $_ isCascadeDeleteOrphan= false;20 protected $_deleteOrphans = false; 21 21 22 public function isCascadeDeleteOrphan()22 public function shouldDeleteOrphans() 23 23 { 24 return $this->_ isCascadeDeleteOrphan;24 return $this->_deleteOrphans; 25 25 } 26 26 } -
trunk/lib/Doctrine/Association/OneToOne.php
r4699 r4718 35 35 { 36 36 /** 37 * Maps the source foreign/primary key fields to the target primary/foreign key fields.37 * Maps the source foreign/primary key columns to the target primary/foreign key columns. 38 38 * i.e. source.id (pk) => target.user_id (fk). 39 * Reverse mapping of _targetToSourceKey Fields.39 * Reverse mapping of _targetToSourceKeyColumns. 40 40 */ 41 41 protected $_sourceToTargetKeyColumns = array(); 42 42 43 43 /** 44 * Maps the target primary/foreign key fields to the source foreign/primary key fields.44 * Maps the target primary/foreign key columns to the source foreign/primary key columns. 45 45 * i.e. target.user_id (fk) => source.id (pk). 46 * Reverse mapping of _sourceToTargetKey Fields.46 * Reverse mapping of _sourceToTargetKeyColumns. 47 47 */ 48 48 protected $_targetToSourceKeyColumns = array(); 49 50 /** Whether to delete orphaned elements (when nulled out, i.e. $foo->other = null) */ 51 protected $_deleteOrphans = false; 49 52 50 53 /** -
trunk/lib/Doctrine/ClassMetadata.php
r4699 r4718 41 41 const INHERITANCE_TYPE_TABLE_PER_CLASS = 'tablePerClass'; 42 42 43 /**44 * Inheritance types enumeration.45 *46 * @var array47 */48 protected static $_inheritanceTypes = array(49 self::INHERITANCE_TYPE_NONE,50 self::INHERITANCE_TYPE_JOINED,51 self::INHERITANCE_TYPE_SINGLE_TABLE,52 self::INHERITANCE_TYPE_TABLE_PER_CLASS53 );54 55 43 /* The Id generator types. TODO: belongs more in a DBAL class */ 56 44 const GENERATOR_TYPE_AUTO = 'auto'; … … 60 48 const GENERATOR_TYPE_NONE = 'none'; 61 49 62 /** 63 * Id Generator types enumeration. 64 * 65 * @var array 66 */ 67 protected static $_generatorTypes = array( 68 self::GENERATOR_TYPE_AUTO, 69 self::GENERATOR_TYPE_SEQUENCE, 70 self::GENERATOR_TYPE_TABLE, 71 self::GENERATOR_TYPE_IDENTITY, 72 self::GENERATOR_TYPE_NONE 73 ); 50 /* The Entity types */ 51 // A regular entity is assumed to have persistent state that Doctrine should manage. 52 const ENTITY_TYPE_REGULAR = 'regular'; 53 // A transient entity is ignored by Doctrine. 54 const ENTITY_TYPE_TRANSIENT = 'transient'; 55 // A mapped superclass entity is itself not persisted by Doctrine but it's 56 // field & association mappings are inherited by subclasses. 57 const ENTITY_TYPE_MAPPED_SUPERCLASS = 'mappedSuperclass'; 74 58 75 59 /** … … 172 156 * entity can have the id attribute, forming a composite key. 173 157 * 174 * - <b>generatorType</b> (string, optional, requires: id) 175 * The generation type used for the field. Optional. Can only be applied on 176 * fields that are marked with the 'id' attribute. The possible values are: 177 * auto, identity, sequence, table. 178 * 179 * - <b>generator</b> (array, optional, requires: generationType=table|sequence) 180 * The generator options for a table or sequence generator. Can only be applied 181 * on fields that have a generationType of 'table' or 'sequence'. 158 * - <b>idGenerator</b> (string, optional) 159 * Either: idGenerator => 'nameOfGenerator', usually only for TABLE/SEQUENCE generators 160 * Or: idGenerator => 'identity' or 'auto' or 'table' or 'sequence' 161 * Note that 'auto', 'table', 'sequence' and 'identity' are reserved names and 162 * therefore cant be used as a generator name! 182 163 * 183 164 * - <b>nullable</b> (boolean, optional) … … 756 737 $this->_identifier[] = $mapping['fieldName']; 757 738 } 758 if (isset($mapping['generatorType'])) { 759 if ( ! in_array($mapping['generatorType'], self::$_generatorTypes)) { 739 if (isset($mapping['idGenerator'])) { 740 if ( ! $this->_isIdGeneratorType($mapping['idGenerator'])) { 741 //TODO: check if the idGenerator specifies an existing generator by name 760 742 throw Doctrine_MappingException::invalidGeneratorType($mapping['generatorType']); 761 743 } else if (count($this->_identifier) > 1) { 762 744 throw Doctrine_MappingException::generatorNotAllowedWithCompositeId(); 763 745 } 764 $this->_generatorType = $mapping[' generatorType'];746 $this->_generatorType = $mapping['idGenerator']; 765 747 } 766 // TODO: validate/complete ' generator' mapping748 // TODO: validate/complete 'tableGenerator' and 'sequenceGenerator' mappings 767 749 768 750 // Check for composite key … … 1171 1153 . " in the root class of the hierarchy."); 1172 1154 } 1173 if ( ! in_array($type, self::$_inheritanceTypes)) {1155 if ( ! $this->_isInheritanceType($type)) { 1174 1156 throw Doctrine_MappingException::invalidInheritanceType($type); 1175 1157 } … … 1411 1393 public function setTableName($tableName) 1412 1394 { 1413 $this->setTableOption('tableName', $this->_em->getConnection() 1414 ->getFormatter()->getTableName($tableName)); 1395 $this->setTableOption('tableName', $tableName); 1415 1396 } 1416 1397 … … 1440 1421 { 1441 1422 return true; 1423 } 1424 1425 /** 1426 * Checks whether the given name identifies an entity type. 1427 * 1428 * @param string $type 1429 * @return boolean 1430 */ 1431 private function _isEntityType($type) 1432 { 1433 return $type == self::ENTITY_TYPE_REGULAR || 1434 $type == self::ENTITY_TYPE_MAPPED_SUPERCLASS || 1435 $type == self::ENTITY_TYPE_TRANSIENT; 1436 } 1437 1438 /** 1439 * Checks whether the given name identifies an inheritance type. 1440 * 1441 * @param string $type 1442 * @return boolean 1443 */ 1444 private function _isInheritanceType($type) 1445 { 1446 return $type == self::INHERITANCE_TYPE_NONE || 1447 $type == self::INHERITANCE_TYPE_SINGLE_TABLE || 1448 $type == self::INHERITANCE_TYPE_JOINED || 1449 $type == self::INHERITANCE_TYPE_TABLE_PER_CLASS; 1450 } 1451 1452 /** 1453 * Checks whether the given name identifies an id generator type. 1454 * 1455 * @param string $type 1456 * @return boolean 1457 */ 1458 private function _isIdGeneratorType($type) 1459 { 1460 return $type == self::GENERATOR_TYPE_AUTO || 1461 $type == self::GENERATOR_TYPE_IDENTITY || 1462 $type == self::GENERATOR_TYPE_SEQUENCE || 1463 $type == self::GENERATOR_TYPE_TABLE || 1464 $type == self::GENERATOR_TYPE_NONE; 1442 1465 } 1443 1466 -
trunk/lib/Doctrine/Compiler.php
r4470 r4718 33 33 * @since 1.0 34 34 * @version $Revision$ 35 * @todo Remove or put in a separate package and look for a maintainer. 35 36 */ 36 37 class Doctrine_Compiler -
trunk/lib/Doctrine/Configuration.php
r4628 r4718 41 41 */ 42 42 private $_attributes = array( 43 'quoteIdentifier ' => false,43 'quoteIdentifiers' => false, 44 44 'indexNameFormat' => '%s_idx', 45 45 'sequenceNameFormat' => '%s_seq', … … 86 86 public function get($name) 87 87 { 88 if ( ! $this->has Attribute($name)) {88 if ( ! $this->has($name)) { 89 89 throw Doctrine_Configuration_Exception::unknownAttribute($name); 90 90 } … … 103 103 public function set($name, $value) 104 104 { 105 if ( ! $this->has Attribute($name)) {105 if ( ! $this->has($name)) { 106 106 throw Doctrine_Configuration_Exception::unknownAttribute($name); 107 107 } -
trunk/lib/Doctrine/Connection.php
r4699 r4718 22 22 #namespace Doctrine::DBAL::Connections; 23 23 24 #use Doctrine::Common::Configuration; 25 24 26 /** 25 * Doctrine_Connection 26 * 27 * A wrapper layer on top of PDO / Doctrine_Adapter 28 * 29 * Doctrine_Connection is the heart of any Doctrine based application. 27 * A thin connection wrapper on top of PDO. 30 28 * 31 29 * 1. Event listeners … … 42 40 * Doctrine_Connection provides many convenience methods such as fetchAll(), fetchOne() etc. 43 41 * 44 * 4. Modular structure45 * Higher level functionality such as schema importing, exporting, sequence handling etc.46 * is divided into modules. For a full list of connection modules see47 * Doctrine_Connection::$_modules48 *49 * @package Doctrine50 * @subpackage Connection51 42 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL 52 43 * @link www.phpdoctrine.org … … 71 62 * 'masterConnectionResolver' => new MyMasterConnectionResolver() 72 63 * 73 * Doctrine::DBAL could ship with a simple standard resolver that uses a primitive64 * Doctrine::DBAL could ship with a simple standard broker that uses a primitive 74 65 * round-robin approach to distribution. User can provide its own resolvers. 75 66 */ … … 86 77 * The Configuration. 87 78 * 88 * @var Configuration79 * @var Doctrine::Common::Configuration 89 80 */ 90 81 protected $_config; … … 93 84 * The EventManager. 94 85 * 95 * @var EventManager86 * @var Doctrine::Commom::EventManager 96 87 */ 97 88 protected $_eventManager; … … 126 117 127 118 /** 128 * An array containing all features this driver supports, keys representing feature 129 * names and values as one of the following (true, false, 'emulated'). 130 * 131 * @var array $supported 132 */ 133 protected $supported = array(); 119 * Boolean flag that indicates whether identifiers should get quoted. 120 * 121 * @var boolean 122 */ 123 protected $_quoteIdentifiers; 134 124 135 125 /** … … 164 154 * List of all available drivers. 165 155 * 166 * @var array $availableDrivers 156 * @var array $availableDrivers 157 * @todo Move elsewhere. 167 158 */ 168 159 private static $_availableDrivers = array( … … 176 167 */ 177 168 protected $_queryCount = 0; 178 179 180 /* 181 * ----------- Mixed attributes (need to split up) --------------- 182 */ 183 /** 184 * @var array $modules an array containing all modules 185 * transaction Doctrine_Transaction driver, handles savepoint and transaction isolation abstraction 186 * 187 * expression Doctrine_Expression driver, handles expression abstraction 188 * 189 * dataDict Doctrine_DataDict driver, handles datatype abstraction 190 * 191 * export Doctrine_Export driver, handles db structure modification abstraction (contains 192 * methods such as alterTable, createConstraint etc.) 193 * import Doctrine_Import driver, handles db schema reading 194 * 195 * sequence Doctrine_Sequence driver, handles sequential id generation and retrieval 196 * 197 * unitOfWork Doctrine_Connection_UnitOfWork handles many orm functionalities such as object 198 * deletion and saving 199 * 200 * formatter Doctrine_Formatter handles data formatting, quoting and escaping 201 * 202 * @see Doctrine_Connection::__get() 203 * @see Doctrine_DataDict 204 * @see Doctrine_Expression 205 * @see Doctrine_Export 206 * @see Doctrine_Transaction 207 * @see Doctrine_Sequence 208 * @see Doctrine_Connection_UnitOfWork 209 * @see Doctrine_Formatter 210 */ 211 private $modules = array('transaction' => false, 212 'expression' => false, 213 'dataDict' => false, 214 'export' => false, 215 'import' => false, 216 'sequence' => false, 217 'formatter' => false, 218 'util' => false, 219 ); 220 169 170 /** 171 * The DatabasePlatform object that provides information about the 172 * database platform used by the connection. 173 * 174 * @var Doctrine::DBAL::Platforms::DatabasePlatform 175 */ 176 protected $_databasePlatform; 221 177 222 178 /** 223 179 * Constructor. 180 * Creates a new Connection. 224 181 * 225 182 * @param array $params The connection parameters. … … 237 194 * Sets the Configuration used by the Connection. 238 195 * 239 * @param Doctrine _Configuration $config196 * @param Doctrine::Common::Configuration $config 240 197 */ 241 198 public function setConfiguration(Doctrine_Configuration $config) … … 260 217 * Sets the EventManager used by the Connection. 261 218 * 262 * @param Doctrine _EventManager $eventManager219 * @param Doctrine::Common::EventManager $eventManager 263 220 */ 264 221 public function setEventManager(Doctrine_EventManager $eventManager) … … 270 227 * Gets the EventManager used by the Connection. 271 228 * 272 * @return EventManager229 * @return Doctrine::Common::EventManager 273 230 */ 274 231 public function getEventManager() … … 280 237 } 281 238 239 /** 240 * Enter description here... 241 * 242 * @param unknown_type $name 243 * @return unknown 244 * @todo Remove. Move properties to DatabasePlatform. 245 */ 282 246 public function getProperty($name) 283 247 { … … 289 253 290 254 /** 291 * returns an array of available PDO drivers 255 * Returns an array of available PDO drivers 256 * @todo Move elsewhere. 292 257 */ 293 258 public static function getAvailableDrivers() … … 297 262 298 263 /** 299 * getName300 264 * returns the name of this driver 301 265 * … … 308 272 309 273 /** 310 * setName311 *312 274 * Sets the name of the connection 313 275 * … … 328 290 { 329 291 return $this->_driverName; 330 }331 332 /**333 * returns the database handler which this connection uses334 *335 * @return PDO the database handler336 * @deprecated337 */338 public function getDbh()339 {340 $this->connect();341 return $this->_pdo;342 292 } 343 293 … … 422 372 $this->_queryCount++; 423 373 } 424 425 /**426 * Checks whether a certain feature is supported.427 *428 * @param string $feature the name of the feature429 * @return boolean whether or not this drivers supports given feature430 */431 public function supports($feature)432 {433 return (isset($this->supported[$feature]) &&434 ($this->supported[$feature] === 'emulated' || $this->supported[$feature]));435 }436 374 437 375 /** … … 639 577 public function quoteIdentifier($str, $checkOption = true) 640 578 { 579 if (is_null($this->_quoteIdentifiers)) { 580 $this->_quoteIdentifiers = $this->_config->get('quoteIdentifiers'); 581 } 582 if ( ! $this->_quoteIdentifiers) { 583 return $str; 584 } 585 641 586 // quick fix for the identifiers that contain a dot 642 587 if (strpos($str, '.')) { 643 588 $e = explode('.', $str); 644 645 return $this->getFormatter()->quoteIdentifier($e[0], $checkOption) . '.' 646 . $this->getFormatter()->quoteIdentifier($e[1], $checkOption); 647 } 648 return $this->getFormatter()->quoteIdentifier($str, $checkOption); 649 } 650 651 /** 652 * convertBooleans 653 * some drivers need the boolean values to be converted into integers 654 * when using DQL API 589 return $this->quoteIdentifier($e[0]) . '.' 590 . $this->quoteIdentifier($e[1]); 591 } 592 593 $q = $this->properties['identifier_quoting']; 594 $str = str_replace($q['end'], $q['escape'] . $q['end'], $str); 595 596 return $q['start'] . $str . $q['end']; 597 } 598 599 /** 600 * Some drivers need the boolean values to be converted into integers 601 * when using DQL API. 655 602 * 656 603 * This method takes care of that conversion … … 661 608 public function convertBooleans($item) 662 609 { 663 return $this->getFormatter()->convertBooleans($item); 610 if (is_array($item)) { 611 foreach ($item as $k => $value) { 612 if (is_bool($value)) { 613 $item[$k] = (int) $value; 614 } 615 } 616 } else { 617 if (is_bool($item)) { 618 $item = (int) $item; 619 } 620 } 621 return $item; 664 622 } 665 623 … … 675 633 return $this->_pdo->quote($input, $type); 676 634 } 635 /** 636 * quote 637 * quotes given input parameter 638 * 639 * @param mixed $input parameter to be quoted 640 * @param string $type 641 * @return mixed 642 */ 643 /*public function quote($input, $type = null) 644 { 645