Commit b5401ee1 authored by romanb's avatar romanb

checkin of occasional work from the past weeks.

parent 9c1c82ca
......@@ -103,13 +103,21 @@ class Doctrine_Association implements Serializable
protected $_sourceFieldName;
/**
* Identifies the field on the owning side that has the mapping for the
* Identifies the field on the owning side that controls the mapping for the
* association. This is only set on the inverse side of an association.
*
* @var string
*/
protected $_mappedByFieldName;
/**
* Identifies the field on the inverse side of a bidirectional association.
* This is only set on the owning side of an association.
*
* @var string
*/
//protected $_inverseSideFieldName;
/**
* The name of the join table, if any.
*
......@@ -127,7 +135,16 @@ class Doctrine_Association implements Serializable
*/
public function __construct(array $mapping)
{
/*$this->_mapping = array(
//$this->_initMappingArray();
//$mapping = $this->_validateAndCompleteMapping($mapping);
//$this->_mapping = array_merge($this->_mapping, $mapping);*/
$this->_validateAndCompleteMapping($mapping);
}
protected function _initMappingArray()
{
$this->_mapping = array(
'fieldName' => null,
'sourceEntity' => null,
'targetEntity' => null,
......@@ -137,10 +154,8 @@ class Doctrine_Association implements Serializable
'accessor' => null,
'mutator' => null,
'optional' => true,
'cascade' => array()
'cascades' => array()
);
$this->_mapping = array_merge($this->_mapping, $mapping);*/
$this->_validateAndCompleteMapping($mapping);
}
/**
......@@ -342,6 +357,36 @@ class Doctrine_Association implements Serializable
return $this->_mappedByFieldName;
}
/*public function getInverseSideFieldName()
{
return $this->_inverseSideFieldName;
}*/
/**
* Marks the association as bidirectional, specifying the field name of
* the inverse side.
* This is called on the owning side, when an inverse side is discovered.
* This does only make sense to call on the owning side.
*
* @param string $inverseSideFieldName
*/
/*public function setBidirectional($inverseSideFieldName)
{
if ( ! $this->_isOwningSide) {
return; //TODO: exception?
}
$this->_inverseSideFieldName = $inverseSideFieldName;
}*/
/**
* Whether the association is bidirectional.
*
* @return boolean
*/
/*public function isBidirectional()
{
return $this->_mappedByFieldName || $this->_inverseSideFieldName;
}*/
/**
* Whether the source field of the association has a custom accessor.
*
......
......@@ -65,6 +65,12 @@ class Doctrine_Association_OneToOne extends Doctrine_Association
parent::__construct($mapping);
}
protected function _initMappingArray()
{
parent::_initMappingArray();
$this->_mapping['deleteOrphans'] = false;
}
/**
* Validates & completes the mapping. Mapping defaults are applied here.
*
......
......@@ -666,7 +666,7 @@ END;
*/
public function buildRecord(array $definition)
{
if ( !isset($definition['className'])) {
if ( ! isset($definition['className'])) {
throw new Doctrine_Builder_Exception('Missing class name.');
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -26,6 +26,9 @@
/**
* The Configuration is the container for all configuration options of Doctrine.
* It combines all configuration options from DBAL & ORM.
*
* INTERNAL: When adding a new configuration option just write a getter/setter
* combination and add the option to the _attributes array with a proper default value.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
......@@ -36,6 +39,8 @@ class Doctrine_Configuration
/**
* The attributes that are contained in the configuration.
* Values are default values. PHP null is replaced by a reference to the Null
* object on instantiation in order to use isset() instead of array_key_exists().
*
* @var array
*/
......@@ -44,12 +49,9 @@ class Doctrine_Configuration
'indexNameFormat' => '%s_idx',
'sequenceNameFormat' => '%s_seq',
'tableNameFormat' => '%s',
'resultCache' => null,
'resultCacheLifeSpan' => null,
'queryCache' => null,
'queryCacheLifeSpan' => null,
'metadataCache' => null,
'metadataCacheLifeSpan' => null
'resultCacheImpl' => null,
'queryCacheImpl' => null,
'metadataCacheImpl' => null,
);
/**
......@@ -78,45 +80,100 @@ class Doctrine_Configuration
}
/**
* Gets the value of a configuration attribute.
* Checks whether the configuration contains/supports an attribute.
*
* @param string $name
* @return mixed
* @return boolean
*/
public function get($name)
public function has($name)
{
if ( ! $this->has($name)) {
throw Doctrine_Configuration_Exception::unknownAttribute($name);
}
if ($this->_attributes[$name] === $this->_nullObject) {
return null;
}
return $this->_attributes[$name];
return isset($this->_attributes[$name]);
}
/**
* Sets the value of a configuration attribute.
*
* @param string $name
* @param mixed $value
*/
public function set($name, $value)
public function getQuoteIdentifiers()
{
return $this->_attributes['quoteIdentifiers'];
}
public function setQuoteIdentifiers($bool)
{
$this->_attributes['quoteIdentifiers'] = (bool)$bool;
}
public function getIndexNameFormat()
{
return $this->_attributes['indexNameFormat'];
}
public function setIndexNameFormat($format)
{
//TODO: check format?
$this->_attributes['indexNameFormat'] = $format;
}
public function getSequenceNameFormat()
{
return $this->_attributes['sequenceNameFormat'];
}
public function setSequenceNameFormat($format)
{
//TODO: check format?
$this->_attributes['sequenceNameFormat'] = $format;
}
public function getTableNameFormat()
{
return $this->_attributes['tableNameFormat'];
}
public function setTableNameFormat($format)
{
if ( ! $this->has($name)) {
throw Doctrine_Configuration_Exception::unknownAttribute($name);
//TODO: check format?
$this->_attributes['tableNameFormat'] = $format;
}
public function getResultCacheImpl()
{
return $this->_attributes['resultCacheImpl'];
}
public function setResultCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['resultCacheImpl'] = $cacheImpl;
}
public function getQueryCacheImpl()
{
return $this->_attributes['queryCacheImpl'];
}
public function setQueryCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['queryCacheImpl'] = $cacheImpl;
}
public function getMetadataCacheImpl()
{
return $this->_attributes['metadataCacheImpl'];
}
public function setMetadataCacheImpl(Doctrine_Cache_Interface $cacheImpl)
{
$this->_attributes['metadataCacheImpl'] = $cacheImpl;
}
public function setCustomTypes(array $types)
{
foreach ($types as $name => $typeClassName) {
Doctrine_DataType::addCustomType($name, $typeClassName);
}
// TODO: do some value checking depending on the attribute
$this->_attributes[$name] = $value;
}
/**
* Checks whether the configuration contains/supports an attribute.
*
* @param string $name
* @return boolean
*/
public function has($name)
public function setTypeOverrides(array $overrides)
{
return isset($this->_attributes[$name]);
foreach ($override as $name => $typeClassName) {
Doctrine_DataType::overrideType($name, $typeClassName);
}
}
}
\ No newline at end of file
......@@ -180,13 +180,26 @@ abstract class Doctrine_Connection
*
* @param array $params The connection parameters.
*/
public function __construct(array $params)
public function __construct(array $params, $config = null, $eventManager = null)
{
if (isset($params['pdo'])) {
$this->_pdo = $params['pdo'];
$this->_isConnected = true;
}
$this->_params = $params;
// Create default config and event manager if none given
if ( ! $config) {
$this->_config = new Doctrine_Configuration();
}
if ( ! $eventManager) {
$this->_eventManager = new Doctrine_EventManager();
}
// create platform
$class = "Doctrine_DatabasePlatform_" . $this->_driverName . "Platform";
$this->_platform = new $class();
$this->_platform->setQuoteIdentifiers($this->_config->getQuoteIdentifiers());
}
/**
......@@ -242,8 +255,7 @@ abstract class Doctrine_Connection
*/
public function getDatabasePlatform()
{
throw new Doctrine_Connection_Exception("No DatabasePlatform available "
. "for connection " . get_class($this));
return $this->_platform;
}
/**
......@@ -558,10 +570,12 @@ abstract class Doctrine_Connection
* @param bool $checkOption check the 'quote_identifier' option
*
* @return string quoted identifier string
* @todo Moved to DatabasePlatform
* @deprecated
*/
public function quoteIdentifier($str, $checkOption = true)
public function quoteIdentifier($str)
{
if (is_null($this->_quoteIdentifiers)) {
/*if (is_null($this->_quoteIdentifiers)) {
$this->_quoteIdentifiers = $this->_config->get('quoteIdentifiers');
}
if ( ! $this->_quoteIdentifiers) {
......@@ -579,7 +593,8 @@ abstract class Doctrine_Connection
$c = $this->_platform->getIdentifierQuoteCharacter();
$str = str_replace($c, $c . $c, $str);
return $c . $str . $c;
return $c . $str . $c;*/
return $this->getDatabasePlatform()->quoteIdentifier($str);
}
/**
......@@ -590,6 +605,7 @@ abstract class Doctrine_Connection
*
* @param array $item
* @return void
* @deprecated Moved to DatabasePlatform
*/
public function convertBooleans($item)
{
......
......@@ -190,18 +190,5 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
}
return $dsn;
}
/**
* Gets the DatabasePlatform for the connection.
*
* @return Doctrine::DBAL::Platforms::MySqlPlatform
*/
public function getDatabasePlatform()
{
if ( ! $this->_platform) {
$this->_platform = new Doctrine_DatabasePlatform_MySqlPlatform();
}
return $this->_platform;
}
}
......@@ -70,7 +70,8 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
* This method takes care of that conversion
*
* @param array $item
* @return void
* @return void
* @deprecated Moved to PostgreSqlPlatform
*/
public function convertBooleans($item)
{
......@@ -94,7 +95,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
* @param string $native determines if the raw version string should be returned
* @return array|string an array or string with version information
*/
public function getServerVersion($native = false)
/*public function getServerVersion($native = false)
{
$query = 'SHOW SERVER_VERSION';
......@@ -124,5 +125,5 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
}
}
return $serverInfo;
}
}*/
}
\ No newline at end of file
......@@ -46,12 +46,46 @@ class Doctrine_ConnectionFactory
'firebird' => 'Doctrine_Connection_Firebird',
'informix' => 'Doctrine_Connection_Informix',
'mock' => 'Doctrine_Connection_Mock');
/**
* The EventManager that is injected into all created Connections.
*
* @var EventManager
*/
private $_eventManager;
/**
* The Configuration that is injected into all created Connections.
*
* @var Configuration
*/
private $_config;
public function __construct()
{
}
/**
* Sets the Configuration that is injected into all Connections.
*
* @param Doctrine_Configuration $config
*/
public function setConfiguration(Doctrine_Configuration $config)
{
$this->_config = $config;
}
/**
* Sets the EventManager that is injected into all Connections.
*
* @param Doctrine_EventManager $eventManager
*/
public function setEventManager(Doctrine_EventManager $eventManager)
{
$this->_eventManager = $eventManager;
}
/**
* Creates a connection object with the specified parameters.
*
......@@ -60,6 +94,14 @@ class Doctrine_ConnectionFactory
*/
public function createConnection(array $params)
{
// create default config and event manager, if not set
if ( ! $this->_config) {
$this->_config = new Doctrine_Configuration();
}
if ( ! $this->_eventManager) {
$this->_eventManager = new Doctrine_EventManager();
}
// check for existing pdo object
if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) {
throw Doctrine_ConnectionFactory_Exception::invalidPDOInstance();
......@@ -70,7 +112,7 @@ class Doctrine_ConnectionFactory
}
$className = $this->_drivers[$params['driver']];
return new $className($params);
return new $className($params, $this->_config, $this->_eventManager);
}
/**
......
<?php
#namespace Doctrine::DBAL::Types;
abstract class Doctrine_DataType
{
private static $_typeObjects = array();
private static $_typesMap = array(
'integer' => 'Doctrine_DataType_IntegerType',
'string' => 'Doctrine_DataType_StringType',
'text' => 'Doctrine_DataType_TextType',
'datetime' => 'Doctrine_DataType_DateTimeType',
'decimal' => 'Doctrine_DataType_DecimalType',
'double' => 'Doctrine_DataType_DoubleType'
);
public function convertToDatabaseValue($value, Doctrine_DatabasePlatform $platform)
{
return $value;
}
public function convertToObjectValue($value)
{
return $value;
}
abstract public function getDefaultLength(Doctrine_DatabasePlatform $platform);
abstract public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform);
abstract public function getName();
/**
* Factory method.
*
* @param string $name The name of the type (as returned by getName()).
* @return Doctrine::DBAL::Types::Type
*/
public static function getType($name)
{
if ( ! isset(self::$_typeObjects[$name])) {
if ( ! isset(self::$_typesMap[$name])) {
throw Doctrine_Exception::unknownType($name);
}
self::$_typeObjects[$name] = new self::$_typesMap[$name]();
}
return self::$_typeObjects[$name];
}
/**
* Adds a custom type to the type map.
*
* @param string $name Name of the type. This should correspond to what
* getName() returns.
* @param string $className The class name of the custom type.
*/
public static function addCustomType($name, $className)
{
if (isset(self::$_typesMap[$name])) {
throw Doctrine_Exception::typeExists($name);
}
self::$_typesMap[$name] = $className;
}
/**
* Overrides an already defined type to use a different implementation.
*
* @param string $name
* @param string $className
*/
public static function overrideType($name, $className)
{
if ( ! isset(self::$_typesMap[$name])) {
throw Doctrine_Exception::typeNotFound($name);
}
self::$_typesMap[$name] = $className;
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps PHP arrays to VARCHAR SQL type.
*
* @since 2.0
*/
class Doctrine_DataType_ArrayType extends Doctrine_DataType
{
public function getName()
{
return 'array';
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL boolean to a PHP boolean.
*
*/
class Doctrine_DataType_BooleanType extends Doctrine_DataType
{
/**
* Enter description here...
*
* @param unknown_type $value
* @override
*/
public function convertToDatabaseValue($value, Doctrine_DatabasePlatform $platform)
{
return $platform->convertBooleans($value);
}
/**
* Enter description here...
*
* @param unknown_type $value
* @return unknown
* @override
*/
public function convertToObjectValue($value)
{
return (bool)$value;
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL DATETIME to a PHP DateTime object.
*
* @since 2.0
*/
class Doctrine_DataType_DateTimeType extends Doctrine_DataType
{
/**
* Enter description here...
*
* @param unknown_type $value
* @param Doctrine_DatabasePlatform $platform
* @override
*/
public function convertToDatabaseValue($value, Doctrine_DatabasePlatform $platform)
{
//TODO: howto? dbms specific? delegate to platform?
}
/**
* Enter description here...
*
* @param string $value
* @return DateTime
* @override
*/
public function convertToObjectValue($value)
{
return new DateTime($value);
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL DECIMAL to a PHP double.
*
*/
class Doctrine_DataType_DecimalType extends Doctrine_DataType
{
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL INT/MEDIUMINT/BIGINT to a PHP integer.
*
*/
class Doctrine_DataType_IntegerType extends Doctrine_DataType
{
public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform)
{
}
}
?>
\ No newline at end of file
<?php
#namespace Doctrine::DBAL::Types;
/**
* Type that maps an SQL VARCHAR to a PHP string.
*
* @since 2.0
*/
class Doctrine_DataType_StringType extends Doctrine_DataType
{
public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform)
{
return $platform->getVarcharDeclaration($fieldDeclaration);
}
public function getDefaultLength(Doctrine_DatabasePlatform $platform)
{
return $platform->getVarcharDefaultLength();
}
public function getName()
{
return 'string';
}
}
?>
\ No newline at end of file
<?php
/**
* Type that maps an SQL CLOB to a PHP string.
*
* @since 2.0
*/
class Doctrine_DataType_TextType extends Doctrine_DataType
{
/**
* Enter description here...
*
* @param array $fieldDeclaration
* @param Doctrine_DatabasePlatform $platform
* @return unknown
* @override
*/
public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform)
{
return $platform->getClobDeclarationSql($fieldDeclaration);
}
}
?>
\ No newline at end of file
This diff is collapsed.
<?php
class Doctrine_DatabasePlatform_MockPlatform extends Doctrine_DatabasePlatform
{
public function getNativeDeclaration(array $field) {}
public function getPortableDeclaration(array $field) {}
}
?>
\ No newline at end of file
......@@ -429,8 +429,8 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable
if ($this->_class->hasField($fieldName)) {
$old = isset($this->_data[$fieldName]) ? $this->_data[$fieldName] : null;
// NOTE: Common case: $old != $value. Special case: null == 0 (TRUE), which
// is addressed by the type comparison.
if ($old != $value || gettype($old) != gettype($value)) {
// is addressed by xor.
if ($old != $value || (is_null($old) xor is_null($value))) {
$this->_data[$fieldName] = $value;
$this->_dataChangeSet[$fieldName] = array($old => $value);
if ($this->isNew() && $this->_class->isIdentifier($fieldName)) {
......@@ -456,7 +456,10 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable
throw Doctrine_Entity_Exception::invalidField($fieldName);
}
}
/**
* Registers the entity as dirty with the UnitOfWork.
*/
private function _registerDirty()
{
if ($this->_state == self::STATE_MANAGED &&
......@@ -531,35 +534,33 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable
*/
final public function _internalSetReference($name, $value, $completeBidirectional = false)
{
if ($value === Doctrine_Null::$INSTANCE) {
if (is_null($value) || $value === Doctrine_Null::$INSTANCE) {
$this->_references[$name] = $value;
return;
return; // early exit!
}
$rel = $this->_class->getAssociationMapping($name);
if ($rel->isOneToOne() && ! $value instanceof Doctrine_Entity) {
throw Doctrine_Entity_Exception::invalidValueForOneToOneReference();
}
if ($rel->isOneToMany() && ! $value instanceof Doctrine_Collection) {
} else if (($rel->isOneToMany() || $rel->isManyToMany()) && ! $value instanceof Doctrine_Collection) {
throw Doctrine_Entity_Exception::invalidValueForOneToManyReference();
}
if ($rel->isManyToMany() && ! $value instanceof Doctrine_Collection) {
throw Doctrine_Entity_Exception::invalidValueForManyToManyReference();
}
$this->_references[$name] = $value;
if ($completeBidirectional && $rel->isOneToOne()) {
//TODO: check if $rel is bidirectional, if yes create the back-reference
if ($rel->isOwningSide()) {
//TODO: how to check if its bidirectional? should be as efficient as possible
/*$targetClass = $this->_em->getClassMetadata($rel->getTargetEntityName());
if (($invAssoc = $targetClass->getInverseAssociation($name)) !== null) {
$value->_internalSetReference($invAssoc->getSourceFieldName(), $this);
}*/
// If there is an inverse mapping on the target class its bidirectional
$targetClass = $this->_em->getClassMetadata($rel->getTargetEntityName());
if ($targetClass->hasInverseAssociationMapping($name)) {
$value->_internalSetReference(
$targetClass->getInverseAssociationMapping($name)->getSourceFieldName(),
$this
);
}
} else {
// for sure bi-directional, as there is no inverse side in unidirectional
// for sure bidirectional, as there is no inverse side in unidirectional
$value->_internalSetReference($rel->getMappedByFieldName(), $this);
}
}
......
......@@ -653,6 +653,35 @@ class Doctrine_EntityManager
return $this->_unitOfWork;
}
/**
* Enter description here...
*
* @param unknown_type $type
* @param unknown_type $class
*/
/*public function getIdGenerator($class)
{
$type = $class->getIdGeneratorType();
if ($type == Doctrine_ClassMetadata::GENERATOR_TYPE_IDENTITY) {
if ( ! isset($this->_idGenerators[$type])) {
$this->_idGenerators[$type] = new Doctrine_Id_IdentityGenerator($this);
}
} else if ($type == Doctrine_ClassMetadata::GENERATOR_TYPE_SEQUENCE) {
if ( ! isset($this->_idGenerators[$type])) {
$this->_idGenerators[$type] = new Doctrine_Id_SequenceGenerator($this);
}
} else if ($type == Doctrine_ClassMetadata::GENERATOR_TYPE_TABLE) {
if ( ! isset($this->_idGenerators[$type])) {
$this->_idGenerators[$type] = new Doctrine_Id_TableGenerator($this);
}
}
$generator = $this->_idGenerators[$type];
$generator->configureForClass($class);
return $generator;
}*/
}
?>
\ No newline at end of file
......@@ -59,7 +59,7 @@ class Doctrine_EntityManagerFactory
*/
public function __construct()
{
$this->_connFactory = new Doctrine_ConnectionFactory();
}
/**
......@@ -93,16 +93,20 @@ class Doctrine_EntityManagerFactory
*/
public function createEntityManager($connParams, $name = null)
{
if ( ! $this->_config) {
$this->_config = new Doctrine_Configuration();
}
if ( ! $this->_eventManager) {
$this->_eventManager = new Doctrine_EventManager();
if ( ! $this->_connFactory) {
// Initialize connection factory
$this->_connFactory = new Doctrine_ConnectionFactory();
if ( ! $this->_config) {
$this->_config = new Doctrine_Configuration();
}
if ( ! $this->_eventManager) {
$this->_eventManager = new Doctrine_EventManager();
}
$this->_connFactory->setConfiguration($this->_config);
$this->_connFactory->setEventManager($this->_eventManager);
}
$conn = $this->_connFactory->createConnection($connParams);
$conn->setEventManager($this->_eventManager);
$conn->setConfiguration($this->_config);
$em = new Doctrine_EntityManager($conn);
$em->setEventManager($this->_eventManager);
......
......@@ -123,6 +123,7 @@ abstract class Doctrine_EntityPersister_Abstract
if ($class->isIdGeneratorIdentity()) {
//TODO: Postgres IDENTITY columns (SERIAL) use a sequence, so we need to pass the
// sequence name to lastInsertId().
//TODO: $this->_em->getIdGenerator($class)->generate();
$entity->_assignIdentifier($this->_conn->lastInsertId());
}
}
......@@ -312,6 +313,8 @@ abstract class Doctrine_EntityPersister_Abstract
default:
$result[$columnName] = $newVal;
}
/*$result[$columnName] = $type->convertToDatabaseValue(
$newVal, $this->_em->getConnection()->getDatabasePlatform());*/
}
// @todo Cleanup
......
......@@ -96,6 +96,8 @@ class Doctrine_EntityRepository
$values = is_array($id) ? array_values($id) : array($id);
$keys = $this->_classMetadata->getIdentifier();
}
//TODO: check identity map?
return $this->_createQuery()
->where(implode(' = ? AND ', $keys) . ' = ?')
......
......@@ -73,7 +73,8 @@ class Doctrine_Hydrator_RecordDriver
$relation = $entity->getClass()->getAssociationMapping($name);
$relatedClass = $this->_em->getClassMetadata($relation->getTargetEntityName());
$coll = $this->getElementCollection($relatedClass->getClassName());
$coll->setReference($entity, $relation);
$coll->_setOwner($entity, $relation);
$coll->_setHydrationFlag(true);
$entity->_internalSetReference($name, $coll, true);
$this->_initializedRelations[$entity->getOid()][$name] = true;
}
......@@ -145,7 +146,8 @@ class Doctrine_Hydrator_RecordDriver
{
// take snapshots from all initialized collections
foreach ($this->_collections as $coll) {
$coll->takeSnapshot();
$coll->_takeSnapshot();
$coll->_setHydrationFlag(false);
}
$this->_collections = array();
$this->_initializedRelations = array();
......
......@@ -400,6 +400,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$rowData[$dqlAlias][$fieldName] = $this->prepareValue(
$class, $fieldName, $value, $cache[$key]['type']);
}
//$rowData[$dqlAlias][$fieldName] = $cache[$key]['type']->convertToObjectValue($value);
if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) {
$nonemptyComponents[$dqlAlias] = true;
......@@ -468,6 +469,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$rowData[$dqlAlias . '_' . $fieldName] = $this->prepareValue(
$class, $fieldName, $value, $cache[$key]['type']);
}
//$rowData[$dqlAlias . '_' . $fieldName] = $cache[$key]['type']->convertToObjectValue($value);
}
return $rowData;
......
<?php
#namespace Doctrine::DBAL::Id;
/**
* Enter description here...
*
* @todo Rename to AbstractIdGenerator
*/
abstract class Doctrine_Id_AbstractIdGenerator
{
protected $_em;
public function __construct(Doctrine_EntityManager $em)
{
$this->_em = $em;
}
abstract public function configureForClass(Doctrine_ClassMetadata $class);
abstract public function generate();
}
?>
\ No newline at end of file
<?php
class Doctrine_Id_IdentityGenerator extends Doctrine_Id_AbstractIdGenerator
{
public function generate(Doctrine_EntityManager $em)
{
}
}
?>
\ No newline at end of file
<?php
?>
\ No newline at end of file
<?php
?>
\ No newline at end of file
......@@ -19,7 +19,7 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::DBAL::Import;
#namespace Doctrine::ORM::Import;
/**
* class Doctrine_Import
......@@ -64,11 +64,11 @@ class Doctrine_Import extends Doctrine_Connection_Module
$builder->setOptions($options);
$classes = array();
foreach ($connection->import->listTables() as $table) {
foreach ($connection->getSchemaManager()->listTables() as $table) {
$definition = array();
$definition['tableName'] = $table;
$definition['className'] = Doctrine_Inflector::classify($table);
$definition['columns'] = $connection->import->listTableColumns($table);
$definition['columns'] = $connection->getSchemaManager()->listTableColumns($table);
$builder->buildRecord($definition);
......
......@@ -27,7 +27,7 @@
* @subpackage Query
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @since 2.0
* @version $Revision: 1393 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
......
......@@ -238,7 +238,7 @@ class Doctrine_Query_Parser
throw new Doctrine_Query_Parser_Exception(implode("\r\n", $this->_errors));
}
// Assign the SQL executor in parser result
// Assign the executor in parser result
$this->_parserResult->setSqlExecutor(Doctrine_Query_SqlExecutor_Abstract::create($AST));
return $this->_parserResult;
......
......@@ -19,8 +19,6 @@
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Query_AbstractResult');
/**
* Doctrine_Query_ParserResult
*
......
......@@ -19,8 +19,6 @@
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Query_AbstractResult');
/**
* Doctrine_Query_QueryResult
*
......@@ -30,7 +28,7 @@ Doctrine::autoload('Doctrine_Query_AbstractResult');
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 1.0
* @since 2.0
* @version $Revision$
*/
class Doctrine_Query_QueryResult extends Doctrine_Query_AbstractResult
......
......@@ -28,7 +28,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo Remove
*/
class Doctrine_Query_Registry
{
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Query_Exception');
/**
* Doctrine_Query_Exception
*
......@@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Query_Exception');
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo Remove
*/
class Doctrine_Query_Registry_Exception extends Doctrine_Query_Exception
{ }
\ No newline at end of file
......@@ -102,9 +102,7 @@ class Doctrine_Query_Scanner
foreach ($matches as $match) {
$value = $match[0];
$type = $this->_getType($value);
$this->_tokens[] = array(
'value' => $value,
'type' => $type,
......@@ -130,7 +128,6 @@ class Doctrine_Query_Scanner
} else {
$type = Doctrine_Query_Token::T_INTEGER;
}
}
if ($value[0] === "'" && $value[strlen($value) - 1] === "'") {
$type = Doctrine_Query_Token::T_STRING;
......
......@@ -31,7 +31,6 @@
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
* @todo Merge into DatabasePlatform.
*/
abstract class Doctrine_Query_SqlBuilder
{
......
......@@ -28,10 +28,7 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @todo Give the tokenizer state, make it better work together with Doctrine_Query and maybe
* take out commonly used string manipulation methods
* into a stateless StringUtil? class. This tokenizer should be concerned with tokenizing
* DQL strings.
* @todo Remove.
*/
class Doctrine_Query_Tokenizer
{
......
......@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Exception');
/**
* Doctrine_Query_Exception
*
......@@ -29,6 +29,7 @@ Doctrine::autoload('Doctrine_Exception');
* @since 1.0
* @version $Revision: 2702 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Remove
*/
class Doctrine_Query_Tokenizer_Exception extends Doctrine_Exception
{ }
\ No newline at end of file
......@@ -299,7 +299,7 @@ class Doctrine_Schema_MsSqlSchemaManager extends Doctrine_Schema_SchemaManager
$val['type'] = $type;
$val['identity'] = $identity;
$decl = $this->conn->dataDict->getPortableDeclaration($val);
$decl = $this->conn->getDatabasePlatform()->getPortableDeclaration($val);
$description = array(
'name' => $val['column_name'],
......
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,7 @@
* - terminals begin with a lower case character
* - parentheses (...) are used for grouping
* - square brackets [...] are used for defining an optional part, eg. zero or
* one time time
* one time
* - curly brackets {...} are used for repetion, eg. zero or more times
* - double quotation marks "..." define a terminal string
* - a vertical bar | represents an alternative
......@@ -14,69 +14,69 @@
* Initially Select and Sub-select DQL will not support LIMIT and OFFSET (due to limit-subquery algorithm)
*/
QueryLanguage = SelectStatement | UpdateStatement | DeleteStatement
QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement
SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
UpdateStatement = UpdateClause [WhereClause]
DeleteStatement = DeleteClause [WhereClause]
SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
UpdateStatement ::= UpdateClause [WhereClause]
DeleteStatement ::= DeleteClause [WhereClause]
Subselect = SimpleSelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
SelectClause = "SELECT" ["ALL" | "DISTINCT"] SelectExpression {"," SelectExpression}
SimpleSelectClause = "SELECT" ["ALL" | "DISTINCT"] SelectExpression
DeleteClause = "DELETE" ["FROM"] VariableDeclaration
WhereClause = "WHERE" ConditionalExpression
FromClause = "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
HavingClause = "HAVING" ConditionalExpression
GroupByClause = "GROUP" "BY" GroupByItem {"," GroupByItem}
OrderByClause = "ORDER" "BY" OrderByItem {"," OrderByItem}
LimitClause = "LIMIT" integer
OffsetClause = "OFFSET" integer
UpdateClause = "UPDATE" VariableDeclaration "SET" UpdateItem {"," UpdateItem}
Subselect ::= SimpleSelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
SelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression {"," SelectExpression}*
SimpleSelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression
DeleteClause ::= "DELETE" ["FROM"] VariableDeclaration
WhereClause ::= "WHERE" ConditionalExpression
FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}*
HavingClause ::= "HAVING" ConditionalExpression
GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}*
OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
LimitClause ::= "LIMIT" integer
OffsetClause ::= "OFFSET" integer
UpdateClause ::= "UPDATE" VariableDeclaration "SET" UpdateItem {"," UpdateItem}*
OrderByItem = Expression ["ASC" | "DESC"]
GroupByItem = PathExpression
UpdateItem = PathExpression "=" (Expression | "NULL")
OrderByItem ::= Expression ["ASC" | "DESC"]
GroupByItem ::= PathExpression
UpdateItem ::= PathExpression "=" (Expression | "NULL")
IdentificationVariableDeclaration = RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}
JoinVariableDeclaration = Join [IndexBy]
RangeVariableDeclaration = identifier {"." identifier} [["AS"] IdentificationVariable]
VariableDeclaration = identifier [["AS"] IdentificationVariable]
IdentificationVariable = identifier
IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
JoinVariableDeclaration ::= Join [IndexBy]
RangeVariableDeclaration ::= identifier {"." identifier}* [["AS"] IdentificationVariable]
VariableDeclaration ::= identifier [["AS"] IdentificationVariable]
IdentificationVariable ::= identifier
Join = ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression]
IndexBy = "INDEX" "BY" identifier
Join ::= ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression]
IndexBy ::= "INDEX" "BY" identifier
ConditionalExpression = ConditionalTerm {"OR" ConditionalTerm}
ConditionalTerm = ConditionalFactor {"AND" ConditionalFactor}
ConditionalFactor = ["NOT"] ConditionalPrimary
ConditionalPrimary = SimpleConditionalExpression | "(" ConditionalExpression ")"
ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*
ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*
ConditionalFactor ::= ["NOT"] ConditionalPrimary
ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
SimpleConditionalExpression
= Expression (ComparisonExpression | BetweenExpression | LikeExpression
::= Expression (ComparisonExpression | BetweenExpression | LikeExpression
| InExpression | NullComparisonExpression) | ExistsExpression
Atom = string | integer | float | boolean | input_parameter
Atom ::= string | integer | float | boolean | input_parameter
Expression = Term {("+" | "-") Term}
Term = Factor {("*" | "/") Factor}
Factor = [("+" | "-")] Primary
Primary = PathExpression | Atom | "(" Expression ")" | Function | AggregateExpression
Expression ::= Term {("+" | "-") Term}*
Term ::= Factor {("*" | "/") Factor}*
Factor ::= [("+" | "-")] Primary
Primary ::= PathExpression | Atom | "(" Expression ")" | Function | AggregateExpression
SelectExpression = (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] FieldIdentificationVariable]
PathExpression = identifier {"." identifier}
PathExpressionEndingWithAsterisk = {identifier "."} "*"
FieldIdentificationVariable = identifier
SelectExpression ::= (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] FieldIdentificationVariable]
PathExpression ::= identifier {"." identifier}*
PathExpressionEndingWithAsterisk ::= {identifier "."}* "*"
FieldIdentificationVariable ::= identifier
AggregateExpression = ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] Expression ")"
AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] Expression ")"
| "COUNT" "(" ["DISTINCT"] (Expression | "*") ")"
QuantifiedExpression = ("ALL" | "ANY" | "SOME") "(" Subselect ")"
BetweenExpression = ["NOT"] "BETWEEN" Expression "AND" Expression
ComparisonExpression = ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" )
InExpression = ["NOT"] "IN" "(" (Atom {"," Atom} | Subselect) ")"
LikeExpression = ["NOT"] "LIKE" Expression ["ESCAPE" string]
NullComparisonExpression = "IS" ["NOT"] "NULL"
ExistsExpression = "EXISTS" "(" Subselect ")"
QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
BetweenExpression ::= ["NOT"] "BETWEEN" Expression "AND" Expression
ComparisonExpression ::= ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" )
InExpression ::= ["NOT"] "IN" "(" (Atom {"," Atom}* | Subselect) ")"
LikeExpression ::= ["NOT"] "LIKE" Expression ["ESCAPE" string]
NullComparisonExpression ::= "IS" ["NOT"] "NULL"
ExistsExpression ::= "EXISTS" "(" Subselect ")"
ComparisonOperator = "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
Function = identifier "(" [Expression {"," Expression}] ")"
Function ::= identifier "(" [Expression {"," Expression}*] ")"
......@@ -11,6 +11,7 @@ require_once 'Orm/Query/AllTests.php';
require_once 'Orm/Hydration/AllTests.php';
require_once 'Orm/Ticket/AllTests.php';
require_once 'Orm/Entity/AllTests.php';
require_once 'Orm/Associations/AllTests.php';
// Tests
require_once 'Orm/UnitOfWorkTest.php';
......@@ -39,6 +40,7 @@ class Orm_AllTests
$suite->addTest(Orm_Hydration_AllTests::suite());
$suite->addTest(Orm_Entity_AllTests::suite());
$suite->addTest(Orm_Ticket_AllTests::suite());
$suite->addTest(Orm_Associations_AllTests::suite());
return $suite;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
class Doctrine_DatabasePlatformMock extends Doctrine_DatabasePlatform
{
public function getNativeDeclaration($field) {}
public function getNativeDeclaration(array $field) {}
public function getPortableDeclaration(array $field) {}
}
......
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