Commit a7699974 authored by romanb's avatar romanb

--no commit message

--no commit message
parent d17a68a4
......@@ -33,7 +33,9 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Consider making Collection & Entity implement ArrayAccess directly.
* This base class is not really a huge benefit.
*/
abstract class Doctrine_Access implements ArrayAccess
{
......
......@@ -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;
/**
......
......@@ -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;
}
}
......
......@@ -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.
......
......@@ -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.
*
* - <b>generatorType</b> (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.
*
* - <b>generator</b> (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'.
* - <b>idGenerator</b> (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!
*
* - <b>nullable</b> (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.
......
......@@ -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
{
......
......@@ -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
......
This diff is collapsed.
......@@ -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.
......
......@@ -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 {
......
......@@ -32,6 +32,7 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @todo Merge all the DataDict classes into the appropriate DBAL DatabasePlatform classes.
*/
class Doctrine_DataDict extends Doctrine_Connection_Module
{
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
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;
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_DataDict');
/**
* @package Doctrine
* @subpackage DataDict
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_DataDict');
/**
* @package Doctrine
* @subpackage DataDict
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_DataDict');
/**
* @package Doctrine
* @subpackage DataDict
......
This diff is collapsed.
......@@ -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()
{
......
......@@ -19,20 +19,22 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::ORM::Persisters;
/**
*
* Base class for all EntityPersisters.
*
* @author Roman Borschel <roman@code-factory.org>
* @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();
}
}
......@@ -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
{
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Export');
/**
* Doctrine_Export_Oracle
*
......
......@@ -30,7 +30,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Merge all Expression classes into the appropriate DBAL DatabasePlatform classes.
*/
class Doctrine_Expression
{
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Connection_Module');
/**
* Doctrine_Expression_Driver
*
......
......@@ -30,219 +30,10 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @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 (<kbd>`</kbd>) -- due to MySQL
* + double quote (<kbd>"</kbd>) -- due to Oracle
* + brackets (<kbd>[</kbd> or <kbd>]</kbd>) -- 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);*/
}
}
......@@ -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 <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
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
*
......
......@@ -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 <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
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));
}*/
/**
*
*/
......
......@@ -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 <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @todo Rename to ObjectDriver
*/
class Doctrine_Hydrator_RecordDriver
{
......
......@@ -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;
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::ORM::Internal;
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
#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
*/
......
......@@ -20,7 +20,6 @@
*/
/**
* Doctrine_Sequence
* The base class for sequence handling drivers.
*
* @package Doctrine
......
......@@ -18,6 +18,8 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::DBAL::Sequences;
/**
* Doctrine_Sequence_Mysql
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Transaction');
/**
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
......
......@@ -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();
......
......@@ -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);
......
......@@ -18,7 +18,7 @@ class CmsArticle extends Doctrine_Entity
'type' => 'integer',
'length' => 4,
'id' => true,
'generatorType' => 'auto'
'idGenerator' => 'auto'
));
$mapping->mapField(array(
'fieldName' => 'topic',
......
......@@ -18,7 +18,7 @@ class CmsUser extends Doctrine_Entity
'type' => 'integer',
'length' => 4,
'id' => true,
'generatorType' => 'auto'
'idGenerator' => 'auto'
));
$mapping->mapField(array(
'fieldName' => 'status',
......
......@@ -16,7 +16,7 @@ class ForumEntry extends Doctrine_Entity
'type' => 'integer',
'length' => 4,
'id' => true,
'generatorType' => 'auto'
'idGenerator' => 'auto'
));
$mapping->mapField(array(
'fieldName' => 'topic',
......
......@@ -34,7 +34,7 @@ class ForumUser extends Doctrine_Entity
'type' => 'integer',
'length' => 4,
'id' => true,
'generatorType' => 'auto'
'idGenerator' => 'auto'
));
$mapping->mapField(array(
'fieldName' => 'username',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment