diff --git a/lib/Doctrine/Access.php b/lib/Doctrine/Access.php index 89e4a4dca..1e62c53e5 100644 --- a/lib/Doctrine/Access.php +++ b/lib/Doctrine/Access.php @@ -33,7 +33,9 @@ * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ - * @author Konsta Vesterinen + * @author Konsta Vesterinen + * @todo Consider making Collection & Entity implement ArrayAccess directly. + * This base class is not really a huge benefit. */ abstract class Doctrine_Access implements ArrayAccess { diff --git a/lib/Doctrine/Association/ManyToMany.php b/lib/Doctrine/Association/ManyToMany.php index a52a06a93..342b4a0fd 100644 --- a/lib/Doctrine/Association/ManyToMany.php +++ b/lib/Doctrine/Association/ManyToMany.php @@ -33,16 +33,16 @@ class Doctrine_Association_ManyToMany extends Doctrine_Association private $_relationTableName; /** The field in the source table that corresponds to the key in the relation table */ - protected $_sourceKeyFields; + protected $_sourceKeyColumns; /** The field in the target table that corresponds to the key in the relation table */ - protected $_targetKeyFields; + protected $_targetKeyColumns; /** The field in the intermediate table that corresponds to the key in the source table */ - protected $_sourceRelationKeyFields; + protected $_sourceRelationKeyColumns; /** The field in the intermediate table that corresponds to the key in the target table */ - protected $_targetRelationKeyFields; + protected $_targetRelationKeyColumns; /** diff --git a/lib/Doctrine/Association/OneToMany.php b/lib/Doctrine/Association/OneToMany.php index f9b5677a4..8a76636bc 100644 --- a/lib/Doctrine/Association/OneToMany.php +++ b/lib/Doctrine/Association/OneToMany.php @@ -4,24 +4,24 @@ class Doctrine_Association_OneToMany extends Doctrine_Association { - /** The target foreign key fields that reference the sourceKeyFields. */ - protected $_targetForeignKeyFields; + /** The target foreign key columns that reference the sourceKeyColumns. */ + protected $_targetForeignKeyColumns; - /** The (typically primary) source key fields that are referenced by the targetForeignKeyFields. */ - protected $_sourceKeyFields; + /** The (typically primary) source key columns that are referenced by the targetForeignKeyColumns. */ + protected $_sourceKeyColumns; - /** This maps the target foreign key fields to the corresponding (primary) source key fields. */ + /** This maps the target foreign key columns to the corresponding (primary) source key columns. */ protected $_targetForeignKeysToSourceKeys; - /** This maps the (primary) source key fields to the corresponding target foreign key fields. */ + /** This maps the (primary) source key columns to the corresponding target foreign key columns. */ protected $_sourceKeysToTargetForeignKeys; /** Whether to delete orphaned elements (removed from the collection) */ - protected $_isCascadeDeleteOrphan = false; + protected $_deleteOrphans = false; - public function isCascadeDeleteOrphan() + public function shouldDeleteOrphans() { - return $this->_isCascadeDeleteOrphan; + return $this->_deleteOrphans; } } diff --git a/lib/Doctrine/Association/OneToOne.php b/lib/Doctrine/Association/OneToOne.php index 851375c60..8d1bb35e3 100644 --- a/lib/Doctrine/Association/OneToOne.php +++ b/lib/Doctrine/Association/OneToOne.php @@ -34,19 +34,22 @@ class Doctrine_Association_OneToOne extends Doctrine_Association { /** - * Maps the source foreign/primary key fields to the target primary/foreign key fields. + * Maps the source foreign/primary key columns to the target primary/foreign key columns. * i.e. source.id (pk) => target.user_id (fk). - * Reverse mapping of _targetToSourceKeyFields. + * Reverse mapping of _targetToSourceKeyColumns. */ protected $_sourceToTargetKeyColumns = array(); /** - * Maps the target primary/foreign key fields to the source foreign/primary key fields. + * Maps the target primary/foreign key columns to the source foreign/primary key columns. * i.e. target.user_id (fk) => source.id (pk). - * Reverse mapping of _sourceToTargetKeyFields. + * Reverse mapping of _sourceToTargetKeyColumns. */ protected $_targetToSourceKeyColumns = array(); + /** Whether to delete orphaned elements (when nulled out, i.e. $foo->other = null) */ + protected $_deleteOrphans = false; + /** * Constructor. * Creates a new OneToOneMapping. diff --git a/lib/Doctrine/ClassMetadata.php b/lib/Doctrine/ClassMetadata.php index 951e65abc..7e78b4b92 100644 --- a/lib/Doctrine/ClassMetadata.php +++ b/lib/Doctrine/ClassMetadata.php @@ -40,18 +40,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable const INHERITANCE_TYPE_SINGLE_TABLE = 'singleTable'; const INHERITANCE_TYPE_TABLE_PER_CLASS = 'tablePerClass'; - /** - * Inheritance types enumeration. - * - * @var array - */ - protected static $_inheritanceTypes = array( - self::INHERITANCE_TYPE_NONE, - self::INHERITANCE_TYPE_JOINED, - self::INHERITANCE_TYPE_SINGLE_TABLE, - self::INHERITANCE_TYPE_TABLE_PER_CLASS - ); - /* The Id generator types. TODO: belongs more in a DBAL class */ const GENERATOR_TYPE_AUTO = 'auto'; const GENERATOR_TYPE_SEQUENCE = 'sequence'; @@ -59,18 +47,14 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable const GENERATOR_TYPE_IDENTITY = 'identity'; const GENERATOR_TYPE_NONE = 'none'; - /** - * Id Generator types enumeration. - * - * @var array - */ - protected static $_generatorTypes = array( - self::GENERATOR_TYPE_AUTO, - self::GENERATOR_TYPE_SEQUENCE, - self::GENERATOR_TYPE_TABLE, - self::GENERATOR_TYPE_IDENTITY, - self::GENERATOR_TYPE_NONE - ); + /* The Entity types */ + // A regular entity is assumed to have persistent state that Doctrine should manage. + const ENTITY_TYPE_REGULAR = 'regular'; + // A transient entity is ignored by Doctrine. + const ENTITY_TYPE_TRANSIENT = 'transient'; + // A mapped superclass entity is itself not persisted by Doctrine but it's + // field & association mappings are inherited by subclasses. + const ENTITY_TYPE_MAPPED_SUPERCLASS = 'mappedSuperclass'; /** * The name of the entity class. @@ -171,14 +155,11 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable * Marks the field as the primary key of the Entity. Multiple fields of an * entity can have the id attribute, forming a composite key. * - * - generatorType (string, optional, requires: id) - * The generation type used for the field. Optional. Can only be applied on - * fields that are marked with the 'id' attribute. The possible values are: - * auto, identity, sequence, table. - * - * - generator (array, optional, requires: generationType=table|sequence) - * The generator options for a table or sequence generator. Can only be applied - * on fields that have a generationType of 'table' or 'sequence'. + * - idGenerator (string, optional) + * Either: idGenerator => 'nameOfGenerator', usually only for TABLE/SEQUENCE generators + * Or: idGenerator => 'identity' or 'auto' or 'table' or 'sequence' + * Note that 'auto', 'table', 'sequence' and 'identity' are reserved names and + * therefore cant be used as a generator name! * * - nullable (boolean, optional) * Whether the column is nullable. Defaults to TRUE. @@ -755,15 +736,16 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable if ( ! in_array($mapping['fieldName'], $this->_identifier)) { $this->_identifier[] = $mapping['fieldName']; } - if (isset($mapping['generatorType'])) { - if ( ! in_array($mapping['generatorType'], self::$_generatorTypes)) { + if (isset($mapping['idGenerator'])) { + if ( ! $this->_isIdGeneratorType($mapping['idGenerator'])) { + //TODO: check if the idGenerator specifies an existing generator by name throw Doctrine_MappingException::invalidGeneratorType($mapping['generatorType']); } else if (count($this->_identifier) > 1) { throw Doctrine_MappingException::generatorNotAllowedWithCompositeId(); } - $this->_generatorType = $mapping['generatorType']; + $this->_generatorType = $mapping['idGenerator']; } - // TODO: validate/complete 'generator' mapping + // TODO: validate/complete 'tableGenerator' and 'sequenceGenerator' mappings // Check for composite key if ( ! $this->_isIdentifierComposite && count($this->_identifier) > 1) { @@ -1170,7 +1152,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable . " must share the same inheritance mapping type and this type must be set" . " in the root class of the hierarchy."); } - if ( ! in_array($type, self::$_inheritanceTypes)) { + if ( ! $this->_isInheritanceType($type)) { throw Doctrine_MappingException::invalidInheritanceType($type); } @@ -1410,8 +1392,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable */ public function setTableName($tableName) { - $this->setTableOption('tableName', $this->_em->getConnection() - ->getFormatter()->getTableName($tableName)); + $this->setTableOption('tableName', $tableName); } /** @@ -1440,6 +1421,48 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable { return true; } + + /** + * Checks whether the given name identifies an entity type. + * + * @param string $type + * @return boolean + */ + private function _isEntityType($type) + { + return $type == self::ENTITY_TYPE_REGULAR || + $type == self::ENTITY_TYPE_MAPPED_SUPERCLASS || + $type == self::ENTITY_TYPE_TRANSIENT; + } + + /** + * Checks whether the given name identifies an inheritance type. + * + * @param string $type + * @return boolean + */ + private function _isInheritanceType($type) + { + return $type == self::INHERITANCE_TYPE_NONE || + $type == self::INHERITANCE_TYPE_SINGLE_TABLE || + $type == self::INHERITANCE_TYPE_JOINED || + $type == self::INHERITANCE_TYPE_TABLE_PER_CLASS; + } + + /** + * Checks whether the given name identifies an id generator type. + * + * @param string $type + * @return boolean + */ + private function _isIdGeneratorType($type) + { + return $type == self::GENERATOR_TYPE_AUTO || + $type == self::GENERATOR_TYPE_IDENTITY || + $type == self::GENERATOR_TYPE_SEQUENCE || + $type == self::GENERATOR_TYPE_TABLE || + $type == self::GENERATOR_TYPE_NONE; + } /** * Adds a one-to-one association mapping. diff --git a/lib/Doctrine/Compiler.php b/lib/Doctrine/Compiler.php index f1ec7f5cd..5b703b975 100644 --- a/lib/Doctrine/Compiler.php +++ b/lib/Doctrine/Compiler.php @@ -31,7 +31,8 @@ * @license http://www.opensource.org/licenses/lgpllicense.php LGPL * @link www.phpdoctrine. * @since 1.0 - * @version $Revision$ + * @version $Revision$ + * @todo Remove or put in a separate package and look for a maintainer. */ class Doctrine_Compiler { diff --git a/lib/Doctrine/Configuration.php b/lib/Doctrine/Configuration.php index c43ea6456..aff0b48b2 100644 --- a/lib/Doctrine/Configuration.php +++ b/lib/Doctrine/Configuration.php @@ -40,7 +40,7 @@ class Doctrine_Configuration * @var array */ private $_attributes = array( - 'quoteIdentifier' => false, + 'quoteIdentifiers' => false, 'indexNameFormat' => '%s_idx', 'sequenceNameFormat' => '%s_seq', 'tableNameFormat' => '%s', @@ -85,7 +85,7 @@ class Doctrine_Configuration */ public function get($name) { - if ( ! $this->hasAttribute($name)) { + if ( ! $this->has($name)) { throw Doctrine_Configuration_Exception::unknownAttribute($name); } if ($this->_attributes[$name] === $this->_nullObject) { @@ -102,7 +102,7 @@ class Doctrine_Configuration */ public function set($name, $value) { - if ( ! $this->hasAttribute($name)) { + if ( ! $this->has($name)) { throw Doctrine_Configuration_Exception::unknownAttribute($name); } // TODO: do some value checking depending on the attribute diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index d10b3b00f..6a5929c7e 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -21,12 +21,10 @@ #namespace Doctrine::DBAL::Connections; +#use Doctrine::Common::Configuration; + /** - * Doctrine_Connection - * - * A wrapper layer on top of PDO / Doctrine_Adapter - * - * Doctrine_Connection is the heart of any Doctrine based application. + * A thin connection wrapper on top of PDO. * * 1. Event listeners * An easy to use, pluggable eventlistener architecture. Aspects such as @@ -41,13 +39,6 @@ * 3. Convenience methods * Doctrine_Connection provides many convenience methods such as fetchAll(), fetchOne() etc. * - * 4. Modular structure - * Higher level functionality such as schema importing, exporting, sequence handling etc. - * is divided into modules. For a full list of connection modules see - * Doctrine_Connection::$_modules - * - * @package Doctrine - * @subpackage Connection * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org * @since 1.0 @@ -70,7 +61,7 @@ * 'masters' => array(...), * 'masterConnectionResolver' => new MyMasterConnectionResolver() * - * Doctrine::DBAL could ship with a simple standard resolver that uses a primitive + * Doctrine::DBAL could ship with a simple standard broker that uses a primitive * round-robin approach to distribution. User can provide its own resolvers. */ abstract class Doctrine_Connection implements Countable @@ -85,14 +76,14 @@ abstract class Doctrine_Connection implements Countable /** * The Configuration. * - * @var Configuration + * @var Doctrine::Common::Configuration */ protected $_config; /** * The EventManager. * - * @var EventManager + * @var Doctrine::Commom::EventManager */ protected $_eventManager; @@ -125,12 +116,11 @@ abstract class Doctrine_Connection implements Countable protected $_isConnected = false; /** - * An array containing all features this driver supports, keys representing feature - * names and values as one of the following (true, false, 'emulated'). + * Boolean flag that indicates whether identifiers should get quoted. * - * @var array $supported + * @var boolean */ - protected $supported = array(); + protected $_quoteIdentifiers; /** * The connection properties. @@ -163,7 +153,8 @@ abstract class Doctrine_Connection implements Countable /** * List of all available drivers. * - * @var array $availableDrivers + * @var array $availableDrivers + * @todo Move elsewhere. */ private static $_availableDrivers = array( 'Mysql', 'Pgsql', 'Oracle', 'Informix', 'Mssql', 'Sqlite', 'Firebird' @@ -175,52 +166,18 @@ abstract class Doctrine_Connection implements Countable * @var integer */ protected $_queryCount = 0; - - /* - * ----------- Mixed attributes (need to split up) --------------- - */ /** - * @var array $modules an array containing all modules - * transaction Doctrine_Transaction driver, handles savepoint and transaction isolation abstraction + * The DatabasePlatform object that provides information about the + * database platform used by the connection. * - * expression Doctrine_Expression driver, handles expression abstraction - * - * dataDict Doctrine_DataDict driver, handles datatype abstraction - * - * export Doctrine_Export driver, handles db structure modification abstraction (contains - * methods such as alterTable, createConstraint etc.) - * import Doctrine_Import driver, handles db schema reading - * - * sequence Doctrine_Sequence driver, handles sequential id generation and retrieval - * - * unitOfWork Doctrine_Connection_UnitOfWork handles many orm functionalities such as object - * deletion and saving - * - * formatter Doctrine_Formatter handles data formatting, quoting and escaping - * - * @see Doctrine_Connection::__get() - * @see Doctrine_DataDict - * @see Doctrine_Expression - * @see Doctrine_Export - * @see Doctrine_Transaction - * @see Doctrine_Sequence - * @see Doctrine_Connection_UnitOfWork - * @see Doctrine_Formatter + * @var Doctrine::DBAL::Platforms::DatabasePlatform */ - private $modules = array('transaction' => false, - 'expression' => false, - 'dataDict' => false, - 'export' => false, - 'import' => false, - 'sequence' => false, - 'formatter' => false, - 'util' => false, - ); - + protected $_databasePlatform; /** * Constructor. + * Creates a new Connection. * * @param array $params The connection parameters. */ @@ -236,7 +193,7 @@ abstract class Doctrine_Connection implements Countable /** * Sets the Configuration used by the Connection. * - * @param Doctrine_Configuration $config + * @param Doctrine::Common::Configuration $config */ public function setConfiguration(Doctrine_Configuration $config) { @@ -259,7 +216,7 @@ abstract class Doctrine_Connection implements Countable /** * Sets the EventManager used by the Connection. * - * @param Doctrine_EventManager $eventManager + * @param Doctrine::Common::EventManager $eventManager */ public function setEventManager(Doctrine_EventManager $eventManager) { @@ -269,7 +226,7 @@ abstract class Doctrine_Connection implements Countable /** * Gets the EventManager used by the Connection. * - * @return EventManager + * @return Doctrine::Common::EventManager */ public function getEventManager() { @@ -279,6 +236,13 @@ abstract class Doctrine_Connection implements Countable return $this->_eventManager; } + /** + * Enter description here... + * + * @param unknown_type $name + * @return unknown + * @todo Remove. Move properties to DatabasePlatform. + */ public function getProperty($name) { if ( ! isset($this->properties[$name])) { @@ -288,7 +252,8 @@ abstract class Doctrine_Connection implements Countable } /** - * returns an array of available PDO drivers + * Returns an array of available PDO drivers + * @todo Move elsewhere. */ public static function getAvailableDrivers() { @@ -296,7 +261,6 @@ abstract class Doctrine_Connection implements Countable } /** - * getName * returns the name of this driver * * @return string the name of this driver @@ -307,8 +271,6 @@ abstract class Doctrine_Connection implements Countable } /** - * setName - * * Sets the name of the connection * * @param string $name @@ -329,18 +291,6 @@ abstract class Doctrine_Connection implements Countable return $this->_driverName; } - /** - * returns the database handler which this connection uses - * - * @return PDO the database handler - * @deprecated - */ - public function getDbh() - { - $this->connect(); - return $this->_pdo; - } - /** * Gets the PDO handle used by the connection. * @@ -421,18 +371,6 @@ abstract class Doctrine_Connection implements Countable { $this->_queryCount++; } - - /** - * Checks whether a certain feature is supported. - * - * @param string $feature the name of the feature - * @return boolean whether or not this drivers supports given feature - */ - public function supports($feature) - { - return (isset($this->supported[$feature]) && - ($this->supported[$feature] === 'emulated' || $this->supported[$feature])); - } /** * Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT @@ -638,20 +576,29 @@ abstract class Doctrine_Connection implements Countable */ public function quoteIdentifier($str, $checkOption = true) { + if (is_null($this->_quoteIdentifiers)) { + $this->_quoteIdentifiers = $this->_config->get('quoteIdentifiers'); + } + if ( ! $this->_quoteIdentifiers) { + return $str; + } + // quick fix for the identifiers that contain a dot if (strpos($str, '.')) { $e = explode('.', $str); - - return $this->getFormatter()->quoteIdentifier($e[0], $checkOption) . '.' - . $this->getFormatter()->quoteIdentifier($e[1], $checkOption); + return $this->quoteIdentifier($e[0]) . '.' + . $this->quoteIdentifier($e[1]); } - return $this->getFormatter()->quoteIdentifier($str, $checkOption); + + $q = $this->properties['identifier_quoting']; + $str = str_replace($q['end'], $q['escape'] . $q['end'], $str); + + return $q['start'] . $str . $q['end']; } /** - * convertBooleans - * some drivers need the boolean values to be converted into integers - * when using DQL API + * Some drivers need the boolean values to be converted into integers + * when using DQL API. * * This method takes care of that conversion * @@ -660,7 +607,18 @@ abstract class Doctrine_Connection implements Countable */ public function convertBooleans($item) { - return $this->getFormatter()->convertBooleans($item); + if (is_array($item)) { + foreach ($item as $k => $value) { + if (is_bool($value)) { + $item[$k] = (int) $value; + } + } + } else { + if (is_bool($item)) { + $item = (int) $item; + } + } + return $item; } /** @@ -674,6 +632,45 @@ abstract class Doctrine_Connection implements Countable { return $this->_pdo->quote($input, $type); } + /** + * quote + * quotes given input parameter + * + * @param mixed $input parameter to be quoted + * @param string $type + * @return mixed + */ + /*public function quote($input, $type = null) + { + if ($type == null) { + $type = gettype($input); + } + switch ($type) { + case 'integer': + case 'enum': + case 'boolean': + case 'double': + case 'float': + case 'bool': + case 'decimal': + case 'int': + return $input; + case 'array': + case 'object': + $input = serialize($input); + case 'date': + case 'time': + case 'timestamp': + case 'string': + case 'char': + case 'varchar': + case 'text': + case 'gzip': + case 'blob': + case 'clob': + return $this->conn->quote($input); + } + }*/ /** * Set the date/time format for the current connection @@ -695,7 +692,7 @@ abstract class Doctrine_Connection implements Countable */ public function fetchAll($statement, array $params = array()) { - return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC); + return $this->execute($statement, $params)->fetchAll(PDO::FETCH_ASSOC); } /** @@ -720,7 +717,7 @@ abstract class Doctrine_Connection implements Countable */ public function fetchRow($statement, array $params = array()) { - return $this->execute($statement, $params)->fetch(Doctrine::FETCH_ASSOC); + return $this->execute($statement, $params)->fetch(PDO::FETCH_ASSOC); } /** @@ -732,7 +729,7 @@ abstract class Doctrine_Connection implements Countable */ public function fetchArray($statement, array $params = array()) { - return $this->execute($statement, $params)->fetch(Doctrine::FETCH_NUM); + return $this->execute($statement, $params)->fetch(PDO::FETCH_NUM); } /** @@ -745,7 +742,7 @@ abstract class Doctrine_Connection implements Countable */ public function fetchColumn($statement, array $params = array(), $colnum = 0) { - return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_COLUMN, $colnum); + return $this->execute($statement, $params)->fetchAll(PDO::FETCH_COLUMN, $colnum); } /** @@ -757,7 +754,7 @@ abstract class Doctrine_Connection implements Countable */ public function fetchAssoc($statement, array $params = array()) { - return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_ASSOC); + return $this->execute($statement, $params)->fetchAll(PDO::FETCH_ASSOC); } /** @@ -769,7 +766,7 @@ abstract class Doctrine_Connection implements Countable */ public function fetchBoth($statement, array $params = array()) { - return $this->execute($statement, $params)->fetchAll(Doctrine::FETCH_BOTH); + return $this->execute($statement, $params)->fetchAll(PDO::FETCH_BOTH); } /** @@ -782,17 +779,16 @@ abstract class Doctrine_Connection implements Countable $this->connect(); try { - $event = new Doctrine_Event($this, Doctrine_Event::CONN_PREPARE, $statement); - - $this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event); + //$event = new Doctrine_Event($this, Doctrine_Event::CONN_PREPARE, $statement); + //$this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event); $stmt = false; - if ( ! $event->skipOperation) { + //if ( ! $event->skipOperation) { $stmt = $this->_pdo->prepare($statement); - } + //} - $this->getAttribute(Doctrine::ATTR_LISTENER)->postPrepare($event); + //$this->getAttribute(Doctrine::ATTR_LISTENER)->postPrepare($event); return new Doctrine_Connection_Statement($this, $stmt); } catch (PDOException $e) { @@ -801,7 +797,7 @@ abstract class Doctrine_Connection implements Countable } /** - * queries the database with limit and offset + * Queries the database with limit and offset * added to the query and returns a Doctrine_Connection_Statement object * * @param string $query @@ -847,15 +843,14 @@ abstract class Doctrine_Connection implements Countable $stmt->execute($params); return $stmt; } else { - $event = new Doctrine_Event($this, Doctrine_Event::CONN_QUERY, $query, $params); + //$event = new Doctrine_Event($this, Doctrine_Event::CONN_QUERY, $query, $params); + //$this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event); - $this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event); - - if ( ! $event->skipOperation) { + //if ( ! $event->skipOperation) { $stmt = $this->_pdo->query($query); $this->_queryCount++; - } - $this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event); + //} + //$this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event); return $stmt; } @@ -881,15 +876,14 @@ abstract class Doctrine_Connection implements Countable return $stmt->rowCount(); } else { - $event = new Doctrine_Event($this, Doctrine_Event::CONN_EXEC, $query, $params); + //$event = new Doctrine_Event($this, Doctrine_Event::CONN_EXEC, $query, $params); + //$this->getAttribute(Doctrine::ATTR_LISTENER)->preExec($event); - $this->getAttribute(Doctrine::ATTR_LISTENER)->preExec($event); - - if ( ! $event->skipOperation) { + //if ( ! $event->skipOperation) { $count = $this->_pdo->exec($query); $this->_queryCount++; - } - $this->getAttribute(Doctrine::ATTR_LISTENER)->postExec($event); + //} + //$this->getAttribute(Doctrine::ATTR_LISTENER)->postExec($event); return $count; } @@ -902,6 +896,7 @@ abstract class Doctrine_Connection implements Countable * * * @return string + * @todo Rather orm stuff */ public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false) { @@ -913,6 +908,7 @@ abstract class Doctrine_Connection implements Countable * context of the limit-subquery algorithm. * * @return string + * @todo Rather ORM stuff */ public function modifyLimitSubquery(Doctrine_Table $rootTable, $query, $limit = false, $offset = false, $isManip = false) @@ -965,7 +961,6 @@ abstract class Doctrine_Connection implements Countable //this->getAttribute(Doctrine::ATTR_LISTENER)->preClose($event); $this->clear(); - unset($this->_pdo); $this->_isConnected = false; @@ -983,7 +978,6 @@ abstract class Doctrine_Connection implements Countable } /** - * errorCode * Fetch the SQLSTATE associated with the last operation on the database handle * * @return integer @@ -996,7 +990,6 @@ abstract class Doctrine_Connection implements Countable } /** - * errorInfo * Fetch extended error information associated with the last operation on the database handle * * @return array @@ -1009,8 +1002,6 @@ abstract class Doctrine_Connection implements Countable } /** - * lastInsertId - * * Returns the ID of the last inserted row, or the last value from a sequence object, * depending on the underlying driver. * @@ -1026,7 +1017,6 @@ abstract class Doctrine_Connection implements Countable } /** - * beginTransaction * Start a transaction or set a savepoint. * * if trying to set a savepoint and there is no active transaction @@ -1044,8 +1034,7 @@ abstract class Doctrine_Connection implements Countable } /** - * commit - * Commit the database changes done during a transaction that is in + * Commits the database changes done during a transaction that is in * progress or release a savepoint. This function may only be called when * auto-committing is disabled, otherwise it will fail. * @@ -1121,8 +1110,6 @@ abstract class Doctrine_Connection implements Countable } /** - * dropDatabase - * * Method for dropping the database for the connection instance * * @return mixed Will return an instance of the exception thrown if the drop @@ -1144,6 +1131,107 @@ abstract class Doctrine_Connection implements Countable return $e; } } + + /** + * Quotes pattern (% and _) characters in a string) + * + * EXPERIMENTAL + * + * WARNING: this function is experimental and may change signature at + * any time until labelled as non-experimental + * + * @param string the input string to quote + * + * @return string quoted string + */ + protected function _escapePattern($text) + { + return $text; + /*if ( ! $this->string_quoting['escape_pattern']) { + return $text; + } + $tmp = $this->conn->string_quoting; + + $text = str_replace($tmp['escape_pattern'], + $tmp['escape_pattern'] . + $tmp['escape_pattern'], $text); + + foreach ($this->wildcards as $wildcard) { + $text = str_replace($wildcard, $tmp['escape_pattern'] . $wildcard, $text); + } + return $text;*/ + } + + /** + * Removes any formatting in an sequence name using the 'seqname_format' option + * + * @param string $sqn string that containts name of a potential sequence + * @return string name of the sequence with possible formatting removed + */ + protected function _fixSequenceName($sqn) + { + $seqPattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $this->conn->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT)).'$/i'; + $seqName = preg_replace($seqPattern, '\\1', $sqn); + + if ($seqName && ! strcasecmp($sqn, $this->getSequenceName($seqName))) { + return $seqName; + } + return $sqn; + } + + /** + * Removes any formatting in an index name using the 'idxname_format' option + * + * @param string $idx string that containts name of anl index + * @return string name of the index with possible formatting removed + */ + protected function _fixIndexName($idx) + { + $indexPattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $this->conn->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT)).'$/i'; + $indexName = preg_replace($indexPattern, '\\1', $idx); + if ($indexName && ! strcasecmp($idx, $this->getIndexName($indexName))) { + return $indexName; + } + return $idx; + } + + /** + * adds sequence name formatting to a sequence name + * + * @param string name of the sequence + * @return string formatted sequence name + */ + protected function _getSequenceName($sqn) + { + return sprintf($this->conn->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT), + preg_replace('/[^a-z0-9_\$.]/i', '_', $sqn)); + } + + /** + * adds index name formatting to a index name + * + * @param string name of the index + * @return string formatted index name + */ + protected function _getIndexName($idx) + { + return sprintf($this->conn->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT), + preg_replace('/[^a-z0-9_\$]/i', '_', $idx)); + } + + /** + * adds table name formatting to a table name + * + * @param string name of the table + * @return string formatted table name + */ + protected function _getTableName($table) + { + return $table; + /* + return sprintf($this->conn->getAttribute(Doctrine::ATTR_TBLNAME_FORMAT), + $table);*/ + } /** * returns a string representation of this object @@ -1159,7 +1247,6 @@ abstract class Doctrine_Connection implements Countable */ /** - * getAttribute * retrieves a database connection attribute * * @param integer $attribute @@ -1182,7 +1269,7 @@ abstract class Doctrine_Connection implements Countable return $this->modules['formatter']; } - public function getSequenceModule() + public function getSequenceManager() { if ( ! $this->modules['sequence']) { $class = "Doctrine_Sequence_" . $this->_driverName; diff --git a/lib/Doctrine/Connection/Mssql.php b/lib/Doctrine/Connection/Mssql.php index 8daa844e5..5eacd697d 100644 --- a/lib/Doctrine/Connection/Mssql.php +++ b/lib/Doctrine/Connection/Mssql.php @@ -69,7 +69,6 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection } /** - * quoteIdentifier * Quote a string so it can be safely used as a table / column name * * Quoting style depends on which database driver is being used. diff --git a/lib/Doctrine/Connection/UnitOfWork.php b/lib/Doctrine/Connection/UnitOfWork.php index 62938ba59..e10c51b71 100644 --- a/lib/Doctrine/Connection/UnitOfWork.php +++ b/lib/Doctrine/Connection/UnitOfWork.php @@ -90,7 +90,6 @@ class Doctrine_Connection_UnitOfWork * entities need to be written to the database. * * @var Doctrine::ORM::Internal::CommitOrderCalculator - * @todo Implementation. Replace buildFlushTree(). */ protected $_commitOrderCalculator; @@ -563,6 +562,13 @@ class Doctrine_Connection_UnitOfWork // In both cases we must commit the inserts instantly. //TODO: Isnt it enough to only execute the inserts instead of full flush? $this->commit(); + /* The following may be better: + $commitOrder = $this->_getCommitOrder($insertNow); + foreach ($commitOrder as $class) { + $this->_executeInserts($class); + } + //... remove them from _newEntities, or dont store them there in the first place + */ } } @@ -593,11 +599,12 @@ class Doctrine_Connection_UnitOfWork $this->_newEntities[$entity->getOid()] = $entity; } else if ( ! $class->usesIdGenerator()) { $insertNow[$entity->getOid()] = $entity; + $this->_newEntities[$entity->getOid()] = $entity; //... } else if ($class->isIdGeneratorSequence()) { // Get the next sequence number //TODO: sequence name? - $id = $this->_em->getConnection()->getSequenceModule()->nextId("foo"); + $id = $this->_em->getConnection()->getSequenceManager()->nextId("foo"); $entity->set($class->getSingleIdentifierFieldName(), $id); $this->registerNew($entity); } else { diff --git a/lib/Doctrine/DataDict.php b/lib/Doctrine/DataDict.php index 161d7c78d..dbc48d728 100644 --- a/lib/Doctrine/DataDict.php +++ b/lib/Doctrine/DataDict.php @@ -32,6 +32,7 @@ * @version $Revision$ * @author Konsta Vesterinen * @author Lukas Smith (PEAR MDB2 library) + * @todo Merge all the DataDict classes into the appropriate DBAL DatabasePlatform classes. */ class Doctrine_DataDict extends Doctrine_Connection_Module { diff --git a/lib/Doctrine/DataDict/Firebird.php b/lib/Doctrine/DataDict/Firebird.php index f576f9bc7..d30a80be5 100644 --- a/lib/Doctrine/DataDict/Firebird.php +++ b/lib/Doctrine/DataDict/Firebird.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_DataDict'); + /** * @package Doctrine * @subpackage DataDict @@ -108,7 +108,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict */ public function getPortableDeclaration($field) { - $length = (isset($field['length']) && $field['length'] > 0) ? $field['length'] : null; + $length = (isset($field['length']) && $field['length'] > 0) ? $field['length'] : null; $type = array(); $unsigned = $fixed = null; diff --git a/lib/Doctrine/DataDict/Informix.php b/lib/Doctrine/DataDict/Informix.php index 7ef21e1ee..72169afd7 100644 --- a/lib/Doctrine/DataDict/Informix.php +++ b/lib/Doctrine/DataDict/Informix.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_DataDict'); + /** * @package Doctrine * @subpackage DataDict diff --git a/lib/Doctrine/DataDict/Mysql.php b/lib/Doctrine/DataDict/Mysql.php index e2afd01d0..40c9c87c4 100644 --- a/lib/Doctrine/DataDict/Mysql.php +++ b/lib/Doctrine/DataDict/Mysql.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_DataDict'); + /** * @package Doctrine * @subpackage DataDict diff --git a/lib/Doctrine/DataDict/Oracle.php b/lib/Doctrine/DataDict/Oracle.php index 2f179e0fe..97fcbda61 100644 --- a/lib/Doctrine/DataDict/Oracle.php +++ b/lib/Doctrine/DataDict/Oracle.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_DataDict'); + /** * @package Doctrine * @subpackage DataDict diff --git a/lib/Doctrine/Entity.php b/lib/Doctrine/Entity.php index 5e7bac542..3798f8efa 100644 --- a/lib/Doctrine/Entity.php +++ b/lib/Doctrine/Entity.php @@ -29,8 +29,6 @@ * are marked INTERNAL: and begin with an underscore "_" to indicate that they * ideally would not be public and to minimize naming collisions. * - * @package Doctrine - * @subpackage Entity * @author Konsta Vesterinen * @author Roman Borschel * @license http://www.opensource.org/licenses/lgpl-license.php LGPL @@ -75,15 +73,15 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable /** * A removed Entity instance is an instance with a persistent identity, - * associated with an EntityManager, that is scheduled for removal from the - * database. + * associated with an EntityManager, whose persistent state has been + * deleted (or is scheduled for deletion). */ const STATE_DELETED = 4; /** * Index used for creating object identifiers (oid's). * - * @var integer $index + * @var integer $index */ private static $_index = 1; @@ -111,7 +109,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable /** * The class descriptor. * - * @var ClassMetadata + * @var Doctrine::ORM::ClassMetadata */ private $_class; @@ -162,7 +160,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable /** * The EntityManager that is responsible for the persistence of the entity. * - * @var Doctrine_EntityManager + * @var Doctrine::ORM::EntityManager */ private $_em; @@ -206,37 +204,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable return $this->_oid; } - /** - * setDefaultValues - * sets the default values for records internal data - * - * @param boolean $overwrite whether or not to overwrite the already set values - * @return boolean - * @todo Job of EntityManager. - * @deprecated - * Setting object-level default field values is much more natural to do in - * the constructor and database-level default values are set by the database. - */ - /*public function assignDefaultValues($overwrite = false) - { - if ( ! $this->_class->hasDefaultValues()) { - return false; - } - foreach ($this->_data as $column => $value) { - $default = $this->_class->getDefaultValueOf($column); - - if ($default === null) { - continue; - } - - if ($value === Doctrine_Null::$INSTANCE || $overwrite) { - $this->_data[$column] = $default; - $this->_modified[] = $column; - $this->_state = Doctrine_Entity::STATE_TDIRTY; - } - } - }*/ - /** * Hydrates this object from given array * @@ -277,10 +244,10 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable /** * INTERNAL: */ - final public function _setIdentifier(array $identifier) + /*final public function _setIdentifier(array $identifier) { $this->_id = $identifier; - } + }*/ /** * Serializes the entity. @@ -298,10 +265,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable $vars = get_object_vars($this); unset($vars['_references']); - unset($vars['_mapper']); - unset($vars['_errorStack']); - unset($vars['_filter']); - unset($vars['_node']); unset($vars['_em']); //$name = (array)$this->_table->getIdentifier(); @@ -417,7 +380,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable } /** - * refresh internal data from the database + * Refresh internal data from the database * * @param bool $deep If true, fetch also current relations. Caution: this deletes * any aggregated values you may have queried beforee @@ -426,7 +389,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * this record represents does not exist anymore) * @return boolean * @todo Implementation to EntityManager. - * @todo Move to ActiveEntity (extends Entity). + * @todo Move to ActiveEntity (extends Entity). Implementation to EntityManager. */ public function refresh($deep = false) { @@ -468,40 +431,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable return $this; } - /** - * refresh - * refres data of related objects from the database - * - * @param string $name name of a related component. - * if set, this method only refreshes the specified related component - * - * @return Doctrine_Entity this object - * @todo Implementation to EntityManager. - * @todo ActiveEntity method. - */ - /*public function refreshRelated($name = null) - { - if (is_null($name)) { - foreach ($this->_class->getRelations() as $rel) { - $this->_references[$rel->getAlias()] = $rel->fetchRelatedFor($this); - } - } else { - $rel = $this->_class->getRelation($name); - $this->_references[$name] = $rel->fetchRelatedFor($this); - } - }*/ - - /** - * clearRelated - * unsets all the relationships this object has - * - * (references to related objects still remain on Table objects) - */ - /*public function clearRelated() - { - $this->_references = array(); - }*/ - /** * Gets the current field values. * @@ -511,16 +440,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable { return $this->_data; } - - /** - * INTERNAL: - * For internal hydration purposes only. - */ - /*final public function _setData(array $data) - { - $this->_data = $data; - $this->_extractIdentifier(); - }*/ /** * INTERNAL: (Usage from within extending classes is intended) @@ -534,9 +453,8 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * @param $name name of the property * @throws Doctrine_Entity_Exception if trying to get an unknown field * @return mixed - * @todo Rename to _get() */ - final public function _rawGet($fieldName) + final public function _get($fieldName) { if (isset($this->_data[$fieldName])) { return $this->_rawGetField($fieldName); @@ -559,9 +477,8 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * @param $name name of the field * @throws Doctrine_Entity_Exception if trying to get an unknown field * @return mixed - * @todo Rename to _set */ - final public function _rawSet($fieldName, $value) + final public function _set($fieldName, $value) { if (isset($this->_data[$fieldName])) { return $this->_rawSetField($fieldName, $value); @@ -578,7 +495,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * * NOTE: Use of this method from outside the scope of an extending class * is strongly discouraged. This method does NOT check whether the field - * exists. _rawGet() in extending classes should be preferred. + * exists. _get() in extending classes should be preferred. * * @param string $fieldName * @return mixed @@ -598,7 +515,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * * NOTE: Use of this method from outside the scope of an extending class * is strongly discouraged. This method does NOT check whether the field - * exists. _rawSet() in extending classes should be preferred. + * exists. _set() in extending classes should be preferred. * * @param string $fieldName * @param mixed $value @@ -616,7 +533,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * is strongly discouraged. This method does NOT check whether the reference * exists. * - * @param unknown_type $fieldName + * @param string $fieldName * @todo Rename to _unsafeGetReference(). */ final public function _rawGetReference($fieldName) @@ -631,8 +548,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * INTERNAL: * Sets a reference to another Entity. * - * NOTE: Use of this method from outside the scope of an extending class - * is strongly discouraged. + * NOTE: Use of this method is strongly discouraged for user-code. * * @param string $fieldName * @param mixed $value @@ -672,7 +588,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable if ($rel instanceof Doctrine_Relation_LocalKey) { $idFieldNames = $value->getTable()->getIdentifier(); if ( ! empty($foreignFieldName) && $foreignFieldName != $idFieldNames[0]) { - $this->set($localFieldName, $value->_rawGet($foreignFieldName)); + $this->set($localFieldName, $value->_get($foreignFieldName)); } else { $this->set($localFieldName, $value); } @@ -689,23 +605,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable $this->_references[$name] = $value; } - /** - * loads all the uninitialized properties from the database. - * - * @return boolean - * @todo ActiveRecord method. - */ - /*public function load() - { - // only load the data from database if the Doctrine_Entity is in proxy state - if ($this->_state == Doctrine_Entity::STATE_PROXY) { - $this->refresh(); - $this->_state = Doctrine_Entity::STATE_CLEAN; - return true; - } - return false; - }*/ - /** * Generic getter. * @@ -903,7 +802,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable /** * Saves the current state of the entity into the database. - * This method also saves associated entities. * * @param Doctrine_Connection $conn optional connection parameter * @return void @@ -942,18 +840,14 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable } /** - * Gets the names and values of all fields that have been modified since - * the entity was last synch'd with the database. + * INTERNAL: + * Gets the changeset of the entities persistent state. * * @return array */ - final public function getModifiedFields() + final public function _getChangeSet() { - $a = array(); - foreach ($this->_modified as $k => $v) { - $a[$v] = $this->_data[$v]; - } - return $a; + //return $this->_changeSet; } /** @@ -964,6 +858,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * @return array * @todo What about a little bit more expressive name? getPreparedData? * @todo Does not look like the best place here ... + * @todo Prop: Move to EntityPersister. There call _getChangeSet() and apply this logic. */ final public function getPrepared(array $array = array()) { @@ -997,18 +892,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable $dataSet[$field] = $this->_class->enumIndex($field, $this->_data[$field]); break; default: - /*if ($this->_data[$field] instanceof Doctrine_Entity) { - // FIXME: composite key support - $ids = $this->_data[$field]->identifier(); - $id = count($ids) > 0 ? array_pop($ids) : null; - $this->_data[$field] = $id; - }*/ - /** TODO: - if ($this->_data[$v] === null) { - throw new Doctrine_Record_Exception('Unexpected null value.'); - } - */ - $dataSet[$field] = $this->_data[$field]; } } @@ -1183,18 +1066,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable return $this->fromArray(Doctrine_Parser::load($data, $type)); } } - - /** - * Checks whether the entity already has a persistent state. - * - * @return boolean TRUE if the object is managed and has persistent state, FALSE otherwise. - * @deprecated - */ - /*public function exists() - { - return ($this->_state !== Doctrine_Entity::STATE_TCLEAN && - $this->_state !== Doctrine_Entity::STATE_TDIRTY); - }*/ /** * Checks whether the entity already has a persistent state. @@ -1218,42 +1089,15 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable } /** - * method for checking existence of properties and Doctrine_Entity references + * Deletes the persistent state of the entity. * - * @param mixed $name name of the property or reference - * @return boolean - * @todo Method name does not reflect the purpose. - */ - /*public function hasRelation($fieldName) - { - if (isset($this->_data[$fieldName]) || isset($this->_id[$fieldName])) { - return true; - } - return $this->_class->hasRelation($fieldName); - }*/ - - /** - * getIterator - * @return Doctrine_Record_Iterator a Doctrine_Record_Iterator that iterates through the data - * @todo Really needed/useful? - */ - /*public function getIterator() - { - return new Doctrine_Record_Iterator($this); - }*/ - - /** - * Deletes the entity. - * - * Triggered events: onPreDelete, onDelete. - * - * @return boolean true on success, false on failure + * @return boolean TRUE on success, FALSE on failure. * @todo ActiveRecord method. */ - public function delete(Doctrine_Connection $conn = null) + public function delete() { // TODO: Forward to EntityManager. There: registerRemoved() on UnitOfWork - return $this->_em->remove($this, $conn); + return $this->_em->remove($this); } /** @@ -1333,7 +1177,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * hasRefence * @param string $name * @return boolean - * @todo Better name? hasAssociation() ? + * @todo Better name? hasAssociation() ? Remove? */ final public function hasReference($name) { @@ -1345,6 +1189,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * * @param string $name * @throws Doctrine_Record_Exception if trying to get an unknown related component + * @todo Better name? Remove? */ final public function obtainReference($name) { @@ -1371,58 +1216,12 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable * * @param string $alias * @param Doctrine_Access $coll + * @todo Name? Remove? */ final public function _setRelated($alias, Doctrine_Access $coll) { $this->_references[$alias] = $coll; } - - /** - * getter for node assciated with this record - * - * @return mixed if tree returns Doctrine_Node otherwise returns false - * @todo Should go to the NestedSet Behavior plugin. - */ - /*public function getNode() - { - if ( ! $this->_class->isTree()) { - return false; - } - - if ( ! isset($this->_node)) { - $this->_node = Doctrine_Node::factory($this, - $this->getTable()->getOption('treeImpl'), - $this->getTable()->getOption('treeOptions')); - } - - return $this->_node; - }*/ - - /** - * revert - * reverts this record to given version, this method only works if versioning plugin - * is enabled - * - * @throws Doctrine_Record_Exception if given version does not exist - * @param integer $version an integer > 1 - * @return Doctrine_Entity this object - * @todo Should go to the Versionable plugin. - */ - public function revert($version) - { - $data = $this->_class - ->getBehavior('Doctrine_Template_Versionable') - ->getAuditLog() - ->getVersion($this, $version); - - if ( ! isset($data[0])) { - throw new Doctrine_Record_Exception('Version ' . $version . ' does not exist!'); - } - - $this->_data = $data[0]; - - return $this; - } /** * Removes links from this record to given records @@ -1549,51 +1348,6 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable return $this; } - - - /** - * __call - * this method is a magic method that is being used for method overloading - * - * the function of this method is to try to find given method from the templates - * this record is using and if it finds given method it will execute it - * - * So, in sense, this method replicates the usage of mixins (as seen in some programming languages) - * - * @param string $method name of the method - * @param array $args method arguments - * @return mixed the return value of the given method - * @todo In order to avoid name clashes and provide a more robust implementation - * we decided that all behaviors should be accessed through getBehavior($name) - * before they're used. - */ - /*public function __call($method, $args) - { - if (($behavior = $this->_class->getBehaviorForMethod($method)) !== false) { - $behavior->setInvoker($this); - return call_user_func_array(array($behavior, $method), $args); - } - - foreach ($this->_class->getBehaviors() as $behavior) { - if (method_exists($behavior, $method)) { - $behavior->setInvoker($this); - $this->_class->addBehaviorMethod($method, $behavior); - return call_user_func_array(array($behavior, $method), $args); - } - } - - throw new Doctrine_Record_Exception(sprintf('Unknown method %s::%s', get_class($this), $method)); - }*/ - - /** - * used to delete node from tree - MUST BE USE TO DELETE RECORD IF TABLE ACTS AS TREE - * - * @todo Should go to the NestedSet Behavior plugin. - */ - /*public function deleteNode() - { - $this->getNode()->delete(); - }*/ /** * Gets the ClassMetadata object that describes the entity class. @@ -1607,7 +1361,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable /** * Gets the EntityManager that is responsible for the persistence of - * the Entity. + * the entity. * * @return Doctrine::ORM::EntityManager */ @@ -1668,5 +1422,4 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable $this->_references = array(); } } - } diff --git a/lib/Doctrine/EntityManager.php b/lib/Doctrine/EntityManager.php index 1bb19182d..63575c663 100644 --- a/lib/Doctrine/EntityManager.php +++ b/lib/Doctrine/EntityManager.php @@ -403,6 +403,27 @@ class Doctrine_EntityManager $this->_unitOfWork->delete($entity); } + /** + * Refreshes the persistent state of the entity from the database. + * + * @param Doctrine_Entity $entity + */ + public function refresh(Doctrine_Entity $entity) + { + //... + } + + /** + * Creates a copy of the given entity. Can create a shallow or a deep copy. + * + * @param Doctrine::ORM::Entity $entity The entity to copy. + * @return Doctrine::ORM::Entity The new entity. + */ + public function copy(Doctrine_Entity $entity, $deep = false) + { + //... + } + /** * Gets the repository for an Entity. * @@ -466,12 +487,6 @@ class Doctrine_EntityManager } else { $entity = new $className; } - - /*if (count($data) < $classMetadata->getMappedColumnCount()) { - $entity->_state(Doctrine_Entity::STATE_PROXY); - } else { - $entity->_state(Doctrine_Entity::STATE_CLEAN); - }*/ return $entity; } @@ -523,20 +538,10 @@ class Doctrine_EntityManager } } - /** - * Gets the UnitOfWork used by the EntityManager. - * - * @return UnitOfWork - */ - /*public function getUnitOfWork() - { - return $this->_unitOfWork; - }*/ - /** * Gets the EventManager used by the EntityManager. * - * @return EventManager + * @return Doctrine::Common::EventManager */ public function getEventManager() { @@ -546,7 +551,7 @@ class Doctrine_EntityManager /** * Sets the EventManager used by the EntityManager. * - * @param Doctrine_EventManager $eventManager + * @param Doctrine::Common::EventManager $eventManager */ public function setEventManager(Doctrine_EventManager $eventManager) { @@ -556,7 +561,7 @@ class Doctrine_EntityManager /** * Sets the Configuration used by the EntityManager. * - * @param Doctrine_Configuration $config + * @param Doctrine::Common::Configuration $config */ public function setConfiguration(Doctrine_Configuration $config) { @@ -566,7 +571,7 @@ class Doctrine_EntityManager /** * Gets the Configuration used by the EntityManager. * - * @return Configuration + * @return Doctrine::Common::Configuration */ public function getConfiguration() { diff --git a/lib/Doctrine/EntityPersister/Abstract.php b/lib/Doctrine/EntityPersister/Abstract.php index d078ff725..38006c61a 100644 --- a/lib/Doctrine/EntityPersister/Abstract.php +++ b/lib/Doctrine/EntityPersister/Abstract.php @@ -19,20 +19,22 @@ * . */ +#namespace Doctrine::ORM::Persisters; + /** - * + * Base class for all EntityPersisters. * * @author Roman Borschel - * @package Doctrine * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version $Revision: 3406 $ * @link www.phpdoctrine.org * @since 2.0 + * @todo Rename to AbstractEntityPersister */ abstract class Doctrine_EntityPersister_Abstract { /** - * The names of all the fields that are available on entities created by this mapper. + * The names of all the fields that are available on entities. */ protected $_fieldNames = array(); @@ -44,9 +46,11 @@ abstract class Doctrine_EntityPersister_Abstract protected $_classMetadata; /** - * The name of the domain class this mapper is used for. + * The name of the Entity the persister is used for. + * + * @var string */ - protected $_domainClassName; + protected $_entityName; /** * The Doctrine_Connection object that the database connection of this mapper. @@ -58,7 +62,7 @@ abstract class Doctrine_EntityPersister_Abstract /** * The EntityManager. * - * @var unknown_type + * @var Doctrine::ORM::EntityManager */ protected $_em; @@ -66,32 +70,102 @@ abstract class Doctrine_EntityPersister_Abstract * Null object. */ private $_nullObject; - - /** - * Enter description here... - * - * @var unknown_type - * @todo To EntityManager. - */ - private $_dataTemplate = array(); - /** - * Constructs a new mapper. - * - * @param string $name The name of the domain class this mapper is used for. - * @param Doctrine_Table $table The table object used for the mapping procedure. - * @throws Doctrine_Connection_Exception if there are no opened connections + * Constructs a new persister. */ public function __construct(Doctrine_EntityManager $em, Doctrine_ClassMetadata $classMetadata) { $this->_em = $em; - $this->_domainClassName = $classMetadata->getClassName(); - $this->_conn = $classMetadata->getConnection(); + $this->_entityName = $classMetadata->getClassName(); + $this->_conn = $em->getConnection(); $this->_classMetadata = $classMetadata; $this->_nullObject = Doctrine_Null::$INSTANCE; } + public function insert(Doctrine_Entity $entity) + { + //... + } + + public function update(Doctrine_Entity $entity) + { + //... + } + + public function delete(Doctrine_Entity $entity) + { + + } + + /** + * Inserts a row into a table. + * + * @todo This method could be used to allow mapping to secondary table(s). + * @see http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#SecondaryTable + */ + protected function _insertRow($tableName, array $data) + { + $this->_conn->insert($tableName, $data); + } + + /** + * Deletes rows of a table. + * + * @todo This method could be used to allow mapping to secondary table(s). + * @see http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#SecondaryTable + */ + protected function _deleteRow($tableName, array $identifierToMatch) + { + $this->_conn->delete($tableName, $identifierToMatch); + } + + /** + * Deletes rows of a table. + * + * @todo This method could be used to allow mapping to secondary table(s). + * @see http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#SecondaryTable + */ + protected function _updateRow($tableName, array $data, array $identifierToMatch) + { + $this->_conn->update($tableName, $data, $identifierToMatch); + } + + public function getClassMetadata() + { + return $this->_classMetadata; + } + + public function getFieldNames() + { + if ($this->_fieldNames) { + return $this->_fieldNames; + } + $this->_fieldNames = $this->_classMetadata->getFieldNames(); + return $this->_fieldNames; + } + + public function getOwningClass($fieldName) + { + return $this->_classMetadata; + } + + /** + * Callback that is invoked during the SQL construction process. + */ + public function getCustomJoins() + { + return array(); + } + + /** + * Callback that is invoked during the SQL construction process. + */ + public function getCustomFields() + { + return array(); + } + /** * Assumes that the keys of the given field array are field names and converts * them to column names. @@ -108,6 +182,14 @@ abstract class Doctrine_EntityPersister_Abstract return $converted; } + + + + ############################################################# + + # The following is old code that needs to be removed/ported + + /** * deletes all related composites * this method is always called internally when a record is deleted @@ -129,19 +211,6 @@ abstract class Doctrine_EntityPersister_Abstract } } - /** - * sets the connection for this class - * - * @params Doctrine_Connection a connection object - * @return Doctrine_Table this object - * @todo refactor - */ - /*public function setConnection(Doctrine_Connection $conn) - { - $this->_conn = $conn; - return $this; - }*/ - /** * Returns the connection the mapper is currently using. * @@ -482,7 +551,7 @@ abstract class Doctrine_EntityPersister_Abstract * @return boolean true on success, false on failure * @throws Doctrine_Mapper_Exception */ - public function delete(Doctrine_Entity $record, Doctrine_Connection $conn = null) + public function delete_old(Doctrine_Entity $record) { if ( ! $record->exists()) { return false; @@ -513,80 +582,5 @@ abstract class Doctrine_EntityPersister_Abstract return true; } - abstract protected function _doDelete(Doctrine_Entity $entity); - - /** - * Inserts a row into a table. - * - * @todo This method could be used to allow mapping to secondary table(s). - * @see http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#SecondaryTable - */ - protected function _insertRow($tableName, array $data) - { - $this->_conn->insert($tableName, $data); - } - - /** - * Deletes rows of a table. - * - * @todo This method could be used to allow mapping to secondary table(s). - * @see http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#SecondaryTable - */ - protected function _deleteRow($tableName, array $identifierToMatch) - { - $this->_conn->delete($tableName, $identifierToMatch); - } - - /** - * Deletes rows of a table. - * - * @todo This method could be used to allow mapping to secondary table(s). - * @see http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#SecondaryTable - */ - protected function _updateRow($tableName, array $data, array $identifierToMatch) - { - $this->_conn->update($tableName, $data, $identifierToMatch); - } - - public function getClassMetadata() - { - return $this->_classMetadata; - } - - /*public function getFieldName($columnName) - { - return $this->_classMetadata->getFieldName($columnName); - }*/ - - public function getFieldNames() - { - if ($this->_fieldNames) { - return $this->_fieldNames; - } - $this->_fieldNames = $this->_classMetadata->getFieldNames(); - return $this->_fieldNames; - } - - public function getOwningClass($fieldName) - { - return $this->_classMetadata; - } - - /* Hooks used during SQL query construction to manipulate the query. */ - - /** - * Callback that is invoked during the SQL construction process. - */ - public function getCustomJoins() - { - return array(); - } - - /** - * Callback that is invoked during the SQL construction process. - */ - public function getCustomFields() - { - return array(); - } + } diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index c83129d70..b9515b316 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -32,6 +32,7 @@ * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ + * @todo Rename to ExportManager. Subclasses: MySqlExportManager, PgSqlExportManager etc. */ class Doctrine_Export extends Doctrine_Connection_Module { diff --git a/lib/Doctrine/Export/Oracle.php b/lib/Doctrine/Export/Oracle.php index 6fb97abd9..f0204e2e5 100644 --- a/lib/Doctrine/Export/Oracle.php +++ b/lib/Doctrine/Export/Oracle.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_Export'); + /** * Doctrine_Export_Oracle * diff --git a/lib/Doctrine/Expression.php b/lib/Doctrine/Expression.php index e603cba74..b1c19b709 100644 --- a/lib/Doctrine/Expression.php +++ b/lib/Doctrine/Expression.php @@ -30,7 +30,8 @@ * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ - * @author Konsta Vesterinen + * @author Konsta Vesterinen + * @todo Merge all Expression classes into the appropriate DBAL DatabasePlatform classes. */ class Doctrine_Expression { diff --git a/lib/Doctrine/Expression/Driver.php b/lib/Doctrine/Expression/Driver.php index 47a2fc4ec..e9e1d67ed 100644 --- a/lib/Doctrine/Expression/Driver.php +++ b/lib/Doctrine/Expression/Driver.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_Connection_Module'); + /** * Doctrine_Expression_Driver * diff --git a/lib/Doctrine/Formatter.php b/lib/Doctrine/Formatter.php index 7dbfa146d..f702c1c03 100644 --- a/lib/Doctrine/Formatter.php +++ b/lib/Doctrine/Formatter.php @@ -30,219 +30,10 @@ * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ - * @author Konsta Vesterinen + * @author Konsta Vesterinen + * @todo Remove */ class Doctrine_Formatter extends Doctrine_Connection_Module { - /** - * Quotes pattern (% and _) characters in a string) - * - * EXPERIMENTAL - * - * WARNING: this function is experimental and may change signature at - * any time until labelled as non-experimental - * - * @param string the input string to quote - * - * @return string quoted string - */ - public function escapePattern($text) - { - return $text; - /*if ( ! $this->string_quoting['escape_pattern']) { - return $text; - } - $tmp = $this->conn->string_quoting; - $text = str_replace($tmp['escape_pattern'], - $tmp['escape_pattern'] . - $tmp['escape_pattern'], $text); - - foreach ($this->wildcards as $wildcard) { - $text = str_replace($wildcard, $tmp['escape_pattern'] . $wildcard, $text); - } - return $text;*/ - } - - /** - * convertBooleans - * some drivers need the boolean values to be converted into integers - * when using DQL API - * - * This method takes care of that conversion - * - * @param array $item - * @return void - */ - public function convertBooleans($item) - { - if (is_array($item)) { - foreach ($item as $k => $value) { - if (is_bool($value)) { - $item[$k] = (int) $value; - } - } - } else { - if (is_bool($item)) { - $item = (int) $item; - } - } - return $item; - } - - /** - * Quote a string so it can be safely used as a table or column name - * - * Delimiting style depends on which database driver is being used. - * - * NOTE: just because you CAN use delimited identifiers doesn't mean - * you SHOULD use them. In general, they end up causing way more - * problems than they solve. - * - * Portability is broken by using the following characters inside - * delimited identifiers: - * + backtick (`) -- due to MySQL - * + double quote (") -- due to Oracle - * + brackets ([ or ]) -- due to Access - * - * Delimited identifiers are known to generally work correctly under - * the following drivers: - * + mssql - * + mysql - * + mysqli - * + oci8 - * + pgsql - * + sqlite - * - * InterBase doesn't seem to be able to use delimited identifiers - * via PHP 4. They work fine under PHP 5. - * - * @param string $str identifier name to be quoted - * @param bool $checkOption check the 'quote_identifier' option - * - * @return string quoted identifier string - */ - public function quoteIdentifier($str, $checkOption = true) - { - if ($checkOption && ! $this->conn->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) { - return $str; - } - $tmp = $this->conn->identifier_quoting; - $str = str_replace($tmp['end'], - $tmp['escape'] . - $tmp['end'], $str); - - return $tmp['start'] . $str . $tmp['end']; - } - - /** - * quote - * quotes given input parameter - * - * @param mixed $input parameter to be quoted - * @param string $type - * @return mixed - */ - public function quote($input, $type = null) - { - if ($type == null) { - $type = gettype($input); - } - switch ($type) { - case 'integer': - case 'enum': - case 'boolean': - case 'double': - case 'float': - case 'bool': - case 'decimal': - case 'int': - return $input; - case 'array': - case 'object': - $input = serialize($input); - case 'date': - case 'time': - case 'timestamp': - case 'string': - case 'char': - case 'varchar': - case 'text': - case 'gzip': - case 'blob': - case 'clob': - return $this->conn->quote($input); - } - } - - /** - * Removes any formatting in an sequence name using the 'seqname_format' option - * - * @param string $sqn string that containts name of a potential sequence - * @return string name of the sequence with possible formatting removed - */ - public function fixSequenceName($sqn) - { - $seqPattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $this->conn->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT)).'$/i'; - $seqName = preg_replace($seqPattern, '\\1', $sqn); - - if ($seqName && ! strcasecmp($sqn, $this->getSequenceName($seqName))) { - return $seqName; - } - return $sqn; - } - - /** - * Removes any formatting in an index name using the 'idxname_format' option - * - * @param string $idx string that containts name of anl index - * @return string name of the index with possible formatting removed - */ - public function fixIndexName($idx) - { - $indexPattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $this->conn->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT)).'$/i'; - $indexName = preg_replace($indexPattern, '\\1', $idx); - if ($indexName && ! strcasecmp($idx, $this->getIndexName($indexName))) { - return $indexName; - } - return $idx; - } - - /** - * adds sequence name formatting to a sequence name - * - * @param string name of the sequence - * @return string formatted sequence name - */ - public function getSequenceName($sqn) - { - return sprintf($this->conn->getAttribute(Doctrine::ATTR_SEQNAME_FORMAT), - preg_replace('/[^a-z0-9_\$.]/i', '_', $sqn)); - } - - /** - * adds index name formatting to a index name - * - * @param string name of the index - * @return string formatted index name - */ - public function getIndexName($idx) - { - return sprintf($this->conn->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT), - preg_replace('/[^a-z0-9_\$]/i', '_', $idx)); - } - - /** - * adds table name formatting to a table name - * - * @param string name of the table - * @return string formatted table name - */ - public function getTableName($table) - { - return $table; - /* - return sprintf($this->conn->getAttribute(Doctrine::ATTR_TBLNAME_FORMAT), - $table);*/ - } } diff --git a/lib/Doctrine/Hydrator/Abstract.php b/lib/Doctrine/Hydrator/Abstract.php index 83c39e49d..06a0432bd 100644 --- a/lib/Doctrine/Hydrator/Abstract.php +++ b/lib/Doctrine/Hydrator/Abstract.php @@ -20,15 +20,14 @@ */ /** - * Doctrine_Hydrator_Abstract + * Base class for all hydrators (ok, we got only 1 currently). * - * @package Doctrine - * @subpackage Hydrate * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org * @since 1.0 * @version $Revision: 3192 $ * @author Konsta Vesterinen + * @author Roman Borschel */ abstract class Doctrine_Hydrator_Abstract { @@ -71,7 +70,6 @@ abstract class Doctrine_Hydrator_Abstract $this->_nullObject = Doctrine_Null::$INSTANCE; } - /** * setHydrationMode * @@ -85,7 +83,6 @@ abstract class Doctrine_Hydrator_Abstract $this->_hydrationMode = $hydrationMode; } - /** * setQueryComponents * @@ -98,7 +95,6 @@ abstract class Doctrine_Hydrator_Abstract $this->_queryComponents = $queryComponents; } - /** * getQueryComponents * @@ -111,7 +107,6 @@ abstract class Doctrine_Hydrator_Abstract return $this->_queryComponents; } - /** * setTableAliasMap * @@ -124,7 +119,6 @@ abstract class Doctrine_Hydrator_Abstract $this->_tableAliasMap = $tableAliasMap; } - /** * getTableAliasMap * @@ -137,7 +131,6 @@ abstract class Doctrine_Hydrator_Abstract return $this->_tableAliasMap; } - /** * hydrateResultSet * diff --git a/lib/Doctrine/Hydrator/ArrayDriver.php b/lib/Doctrine/Hydrator/ArrayDriver.php index 1a4adb8cc..77f8d81f3 100644 --- a/lib/Doctrine/Hydrator/ArrayDriver.php +++ b/lib/Doctrine/Hydrator/ArrayDriver.php @@ -20,16 +20,14 @@ */ /** - * Doctrine_Hydrator_ArrayDriver - * Defines an array fetching strategy. + * Defines an array hydration strategy. * - * @package Doctrine - * @subpackage Hydrate * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ * @author Konsta Vesterinen + * @author Roman Borschel */ class Doctrine_Hydrator_ArrayDriver { @@ -50,14 +48,6 @@ class Doctrine_Hydrator_ArrayDriver return $data; } - /** - * - */ - /*public function isIdentifiable(array $data, Doctrine_Table $table) - { - return ( ! empty($data)); - }*/ - /** * */ diff --git a/lib/Doctrine/Hydrator/RecordDriver.php b/lib/Doctrine/Hydrator/RecordDriver.php index 4bf04ebc3..420dec8b9 100644 --- a/lib/Doctrine/Hydrator/RecordDriver.php +++ b/lib/Doctrine/Hydrator/RecordDriver.php @@ -20,17 +20,15 @@ */ /** - * Doctrine_Hydrator_RecordDriver - * Hydration strategy used for creating graphs of entity objects. + * Hydration strategy used for creating graphs of entities. * - * @package Doctrine - * @subpackage Hydrate * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ * @author Konsta Vesterinen * @author Roman Borschel + * @todo Rename to ObjectDriver */ class Doctrine_Hydrator_RecordDriver { diff --git a/lib/Doctrine/HydratorNew.php b/lib/Doctrine/HydratorNew.php index 51aed774c..664fcf6d9 100644 --- a/lib/Doctrine/HydratorNew.php +++ b/lib/Doctrine/HydratorNew.php @@ -170,10 +170,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract $nonemptyComponents = array(); $rowData = $this->_gatherRowData($data, $cache, $id, $nonemptyComponents); - // 2) Hydrate the data of the root entity from the current row - //$class = $this->_queryComponents[$rootAlias]['metadata']; - //$entityName = $class->getComponentName(); - + // 2) Hydrate the data of the root entity from the current row // Check for an existing element $index = false; if ($isSimpleQuery || ! isset($identifierMap[$rootAlias][$id[$rootAlias]])) { @@ -208,7 +205,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract } // 3) Now hydrate the rest of the data found in the current row, that - // belongs to other (related) Entities. + // belongs to other (related) entities. foreach ($rowData as $dqlAlias => $data) { $index = false; $map = $this->_queryComponents[$dqlAlias]; @@ -295,7 +292,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract /** * Updates the result pointer for an Entity. The result pointers point to the - * last seen instance of each Entity. This is used for graph construction. + * last seen instance of each Entity type. This is used for graph construction. * * @param array $resultPointers The result pointers. * @param array|Collection $coll The element. @@ -540,13 +537,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract case 'enum': case 'boolean': // don't do any conversions on primitive types - break; - //case 'enum': - // return $class->enumValue($fieldName, $value); - //break; - //case 'boolean': - // return (boolean) $value; - //break; + break; case 'array': case 'object': if (is_string($value)) { @@ -556,14 +547,14 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract } return $value; } - break; + break; case 'gzip': $value = gzuncompress($value); if ($value === false) { throw new Doctrine_Hydrator_Exception('Uncompressing of ' . $fieldName . ' failed.'); } return $value; - break; + break; } } return $value; diff --git a/lib/Doctrine/Internal/CommitOrderCalculator.php b/lib/Doctrine/Internal/CommitOrderCalculator.php index 9d345234c..3ce50b557 100644 --- a/lib/Doctrine/Internal/CommitOrderCalculator.php +++ b/lib/Doctrine/Internal/CommitOrderCalculator.php @@ -1,4 +1,23 @@ . + */ #namespace Doctrine::ORM::Internal; diff --git a/lib/Doctrine/Internal/CommitOrderNode.php b/lib/Doctrine/Internal/CommitOrderNode.php index 92c97908d..42a343a07 100644 --- a/lib/Doctrine/Internal/CommitOrderNode.php +++ b/lib/Doctrine/Internal/CommitOrderNode.php @@ -1,9 +1,26 @@ . + */ #namespace Doctrine::ORM::Internal; -#use Doctrine::ORM::Mapping::ClassMetadata; - /** * A CommitOrderNode is a temporary wrapper around ClassMetadata objects * that is used to sort the order of commits. @@ -123,7 +140,7 @@ class Doctrine_Internal_CommitOrderNode } /** - * Adds a directed dependency (an edge). "$this -before-> $other". + * Adds a directed dependency (an edge on the graph). "$this -before-> $other". * * @param Doctrine_Internal_CommitOrderNode $node */ diff --git a/lib/Doctrine/Sequence.php b/lib/Doctrine/Sequence.php index f826624d2..71afd61e7 100644 --- a/lib/Doctrine/Sequence.php +++ b/lib/Doctrine/Sequence.php @@ -20,7 +20,6 @@ */ /** - * Doctrine_Sequence * The base class for sequence handling drivers. * * @package Doctrine diff --git a/lib/Doctrine/Sequence/Mysql.php b/lib/Doctrine/Sequence/Mysql.php index ccca7e819..1ac508c4e 100644 --- a/lib/Doctrine/Sequence/Mysql.php +++ b/lib/Doctrine/Sequence/Mysql.php @@ -18,6 +18,8 @@ * and is licensed under the LGPL. For more information, see * . */ + +#namespace Doctrine::DBAL::Sequences; /** * Doctrine_Sequence_Mysql diff --git a/lib/Doctrine/Transaction/Mssql.php b/lib/Doctrine/Transaction/Mssql.php index 66c25e95d..8094fb887 100644 --- a/lib/Doctrine/Transaction/Mssql.php +++ b/lib/Doctrine/Transaction/Mssql.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_Transaction'); + /** * * @author Konsta Vesterinen diff --git a/tests/Orm/UnitOfWorkTest.php b/tests/Orm/UnitOfWorkTest.php index 650f84eb0..ef3351788 100644 --- a/tests/Orm/UnitOfWorkTest.php +++ b/tests/Orm/UnitOfWorkTest.php @@ -32,7 +32,7 @@ class Orm_UnitOfWorkTest extends Doctrine_OrmTestCase $this->_user->username = 'romanb'; $this->_connectionMock = new Doctrine_ConnectionMock(array()); - $this->_sequenceMock = $this->_connectionMock->getSequenceModule(); + $this->_sequenceMock = $this->_connectionMock->getSequenceManager(); $this->_emMock = new Doctrine_EntityManagerMock($this->_connectionMock); $this->_persisterMock = $this->_emMock->getEntityPersister("ForumUser"); $this->_unitOfWork = $this->_emMock->getUnitOfWork(); diff --git a/tests/lib/mocks/Doctrine_ConnectionMock.php b/tests/lib/mocks/Doctrine_ConnectionMock.php index c913eb3c2..23be1a5fc 100644 --- a/tests/lib/mocks/Doctrine_ConnectionMock.php +++ b/tests/lib/mocks/Doctrine_ConnectionMock.php @@ -7,7 +7,7 @@ class Doctrine_ConnectionMock extends Doctrine_Connection protected $_driverName = 'Mysql'; private $_sequenceModuleMock; - public function getSequenceModule() + public function getSequenceManager() { if ( ! $this->_sequenceModuleMock) { $this->_sequenceModuleMock = new Doctrine_SequenceMock($this); diff --git a/tests/models/cms/CmsArticle.php b/tests/models/cms/CmsArticle.php index b9c820e29..90083948e 100755 --- a/tests/models/cms/CmsArticle.php +++ b/tests/models/cms/CmsArticle.php @@ -18,7 +18,7 @@ class CmsArticle extends Doctrine_Entity 'type' => 'integer', 'length' => 4, 'id' => true, - 'generatorType' => 'auto' + 'idGenerator' => 'auto' )); $mapping->mapField(array( 'fieldName' => 'topic', diff --git a/tests/models/cms/CmsUser.php b/tests/models/cms/CmsUser.php index 146dad6f7..961cf2956 100644 --- a/tests/models/cms/CmsUser.php +++ b/tests/models/cms/CmsUser.php @@ -18,7 +18,7 @@ class CmsUser extends Doctrine_Entity 'type' => 'integer', 'length' => 4, 'id' => true, - 'generatorType' => 'auto' + 'idGenerator' => 'auto' )); $mapping->mapField(array( 'fieldName' => 'status', diff --git a/tests/models/forum/ForumEntry.php b/tests/models/forum/ForumEntry.php index f75e97755..8071906f2 100644 --- a/tests/models/forum/ForumEntry.php +++ b/tests/models/forum/ForumEntry.php @@ -16,7 +16,7 @@ class ForumEntry extends Doctrine_Entity 'type' => 'integer', 'length' => 4, 'id' => true, - 'generatorType' => 'auto' + 'idGenerator' => 'auto' )); $mapping->mapField(array( 'fieldName' => 'topic', diff --git a/tests/models/forum/ForumUser.php b/tests/models/forum/ForumUser.php index 6d4c18eb9..917f00952 100644 --- a/tests/models/forum/ForumUser.php +++ b/tests/models/forum/ForumUser.php @@ -34,7 +34,7 @@ class ForumUser extends Doctrine_Entity 'type' => 'integer', 'length' => 4, 'id' => true, - 'generatorType' => 'auto' + 'idGenerator' => 'auto' )); $mapping->mapField(array( 'fieldName' => 'username',