Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
c43f9588
Commit
c43f9588
authored
Jul 11, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups, improvements, fixes.
parent
3cd7b954
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
191 additions
and
217 deletions
+191
-217
ClassMetadata.php
lib/Doctrine/ClassMetadata.php
+121
-165
Factory.php
lib/Doctrine/ClassMetadata/Factory.php
+2
-2
Entity.php
lib/Doctrine/Entity.php
+4
-4
HydratorNew.php
lib/Doctrine/HydratorNew.php
+37
-38
MappingException.php
lib/Doctrine/MappingException.php
+17
-0
PathExpressionEndingWithAsterisk.php
...ine/Query/Production/PathExpressionEndingWithAsterisk.php
+1
-1
AccessorTest.php
tests/Orm/Entity/AccessorTest.php
+7
-5
AllTests.php
tests/Orm/Entity/AllTests.php
+2
-2
No files found.
lib/Doctrine/ClassMetadata.php
View file @
c43f9588
...
...
@@ -540,14 +540,12 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
/**
* getColumnName
* Gets a column name for a field name.
* If the column name for the field cannot be found, the given field name
* is returned.
*
* returns a column name for a field name.
* if the column name for the field cannot be found
* this method returns the given field name.
*
* @param string $alias column alias
* @return string column name
* @param string $alias The field name.
* @return string The column name.
*/
public
function
getColumnName
(
$fieldName
)
{
...
...
@@ -556,19 +554,30 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
/**
* @deprecated
* Gets the mapping of a (regular) fields that holds some data but not a
* reference to another object.
*
* @param string $fieldName The field name.
* @return array The mapping.
*/
public
function
getColumnDefinition
(
$columnName
)
{
return
$this
->
getColumnMapping
(
$columnName
);
}
public
function
getFieldMapping
(
$fieldName
)
{
return
isset
(
$this
->
_fieldMappings
[
$fieldName
])
?
$this
->
_fieldMappings
[
$fieldName
]
:
false
;
}
/**
* Gets the mapping of an association.
*
* @param string $fieldName The field name that represents the association in
* the object model.
* @return Doctrine::ORM::Mapping::AssociationMapping The mapping.
*/
public
function
getAssociationMapping
(
$fieldName
)
{
//...
}
/**
* Gets the field name for a column name.
* If no field name can be found the column name is returned.
...
...
@@ -588,6 +597,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
*
* @param string $lcColumnName
* @return string
* @todo Better name.
*/
public
function
getFieldNameForLowerColumnName
(
$lcColumnName
)
{
...
...
@@ -640,16 +650,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
throw
new
Doctrine_ClassMetadata_Exception
(
"No field name found for column name '
$lcColumnName
' during lookup."
);
}
/**
* @deprecated
*/
public
function
setColumns
(
array
$definitions
)
{
foreach
(
$definitions
as
$name
=>
$options
)
{
$this
->
setColumn
(
$name
,
$options
[
'type'
],
$options
[
'length'
],
$options
);
}
}
/**
* Maps a field of the class to a database column.
*
...
...
@@ -663,6 +663,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
* By default the column gets appended.
*
* @throws Doctrine_ClassMetadata_Exception If trying use wrongly typed parameter.
* @todo Rename to mapField()/addFieldMapping().
*/
public
function
mapColumn
(
$name
,
$type
,
$length
=
null
,
$options
=
array
())
{
...
...
@@ -783,14 +784,14 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
/**
* Checks whether the
class
mapped class has a default value on any field.
* Checks whether the mapped class has a default value on any field.
*
* @return boolean TRUE if the entity has a default value on any field, otherwise false.
*/
public
function
hasDefaultValues
()
/*
public function hasDefaultValues()
{
return $this->_hasDefaultValues;
}
}
*/
/**
* getDefaultValueOf
...
...
@@ -799,7 +800,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
* @param string $fieldName
* @return mixed
*/
public
function
getDefaultValueOf
(
$fieldName
)
/*
public function getDefaultValueOf($fieldName)
{
if ( ! isset($this->_fieldMappings[$fieldName])) {
throw new Doctrine_Table_Exception("Couldn't get default value. Column ".$fieldName." doesn't exist.");
...
...
@@ -809,10 +810,10 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
} else {
return null;
}
}
}
*/
/**
* Gets the identifier (primary key) field
(s) of the mapped
class.
* Gets the identifier (primary key) field
names of the
class.
*
* @return mixed
* @deprecated Use getIdentifierFieldNames()
...
...
@@ -823,7 +824,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
/**
* Gets the identifier (primary key) field
(s) of the mapped
class.
* Gets the identifier (primary key) field
names of the
class.
*
* @return mixed
*/
...
...
@@ -839,8 +840,11 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
/**
* Gets the type of the identifier (primary key) used by the mapped class. The type
* can be either <tt>Doctrine::IDENTIFIER_NATURAL</tt>, <tt>Doctrine::IDENTIFIER_AUTOINCREMENT</tt>,
* <tt>Doctrine::IDENTIFIER_SEQUENCE</tt> or <tt>Doctrine::IDENTIFIER_COMPOSITE</tt>.
* can be either
* <tt>Doctrine::IDENTIFIER_NATURAL</tt>,
* <tt>Doctrine::IDENTIFIER_AUTOINCREMENT</tt>,
* <tt>Doctrine::IDENTIFIER_SEQUENCE</tt> or
* <tt>Doctrine::IDENTIFIER_COMPOSITE</tt>.
*
* @return integer
*/
...
...
@@ -857,16 +861,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
$this
->
_identifierType
=
$type
;
}
/**
* hasColumn
* @return boolean
* @deprecated
*/
public
function
hasColumn
(
$columnName
)
{
return
isset
(
$this
->
_fieldNames
[
$columnName
]);
}
public
function
hasMappedColumn
(
$columnName
)
{
return
isset
(
$this
->
_fieldNames
[
$columnName
]);
...
...
@@ -885,14 +879,14 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
* @param string $fieldName
* @return array
*/
public
function
getEnumValues
(
$fieldName
)
/*
public function getEnumValues($fieldName)
{
if (isset($this->_fieldMappings[$fieldName]['values'])) {
return $this->_fieldMappings[$fieldName]['values'];
} else {
return array();
}
}
}
*/
/**
* enumValue
...
...
@@ -901,7 +895,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
* @param integer $index
* @return mixed
*/
public
function
enumValue
(
$fieldName
,
$index
)
/*
public function enumValue($fieldName, $index)
{
if ($index instanceof Doctrine_Null) {
return $index;
...
...
@@ -921,7 +915,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
$this->_enumValues[$fieldName][$index] = $enumValue;
return $enumValue;
}
}
*/
/**
* enumIndex
...
...
@@ -930,7 +924,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
* @param mixed $value
* @return mixed
*/
public
function
enumIndex
(
$fieldName
,
$value
)
/*
public function enumIndex($fieldName, $value)
{
$values = $this->getEnumValues($fieldName);
$index = array_search($value, $values);
...
...
@@ -939,7 +933,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
return $value;
}
}
*/
/**
* getColumnCount
...
...
@@ -947,22 +941,23 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
* @return integer the number of columns in this table
* @deprecated
*/
public
function
getColumnCount
()
/*
public function getColumnCount()
{
return $this->_columnCount;
}
}
*/
/**
* getMappedColumnCount
*
* @return integer the number of mapped columns in the class.
*/
public
function
getMapped
Column
Count
()
public
function
getMapped
Field
Count
()
{
return
$this
->
_columnCount
;
}
/**
* Gets the custom accessor of a field.
*
* @return string The name of the accessor (getter) method or NULL if the field does
* not have a custom accessor.
...
...
@@ -974,6 +969,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
/**
* Gets the custom mutator of a field.
*
* @return string The name of the mutator (setter) method or NULL if the field does
* not have a custom mutator.
...
...
@@ -985,26 +981,10 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
/**
* returns all columns and their definitions
*
* @return array
* @deprecated
*/
public
function
getColumns
()
{
return
$this
->
_fieldMappings
;
}
/**
* Gets all mapped columns and their mapping definitions.
* Gets all field mappings.
*
* @return
array
* @return
unknown
*/
public
function
getMappedColumns
()
{
return
$this
->
_fieldMappings
;
}
public
function
getFieldMappings
()
{
return
$this
->
_fieldMappings
;
...
...
@@ -1016,7 +996,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
*
* @return boolean
*/
public
function
removeColumn
(
$fieldName
)
/*
public function removeColumn($fieldName)
{
$columnName = array_search($fieldName, $this->_fieldNames);
...
...
@@ -1029,7 +1009,7 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
$this->_columnCount--;
return false;
}
}
*/
/**
* returns an array containing all the column names.
...
...
@@ -1076,35 +1056,12 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
* @return mixed array on success, false on failure
* @deprecated
*/
public
function
getDefinitionOf
(
$fieldName
)
/*
public function getDefinitionOf($fieldName)
{
$columnName = $this->getColumnName($fieldName);
return $this->getColumnDefinition($columnName);
}
/**
* Gets the mapping information for a field.
*
* @param string $fieldName
* @return array
*/
public
function
getMappingForField
(
$fieldName
)
{
return
$this
->
_fieldMappings
[
$fieldName
];
}
/**
* getTypeOf
*
* @return mixed string on success, false on failure
* @deprecated
*/
public
function
getTypeOf
(
$fieldName
)
{
return
$this
->
getTypeOfColumn
(
$this
->
getColumnName
(
$fieldName
));
}
}*/
/**
* Gets the type of a field.
...
...
@@ -1163,72 +1120,6 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
//...
}
public
function
bindRelation
(
$args
,
$type
)
{
return
$this
->
bind
(
$args
,
$type
);
}
/**
* DESCRIBE WHAT THIS METHOD DOES, PLEASE!
*
* @todo Name proposal: addRelation
*/
public
function
bind
(
$args
,
$type
)
{
$options
=
array
();
$options
[
'type'
]
=
$type
;
if
(
!
isset
(
$args
[
1
]))
{
$args
[
1
]
=
array
();
}
if
(
!
is_array
(
$args
[
1
]))
{
try
{
throw
new
Exception
();
}
catch
(
Exception
$e
)
{
echo
$e
->
getTraceAsString
();
}
}
$options
=
array_merge
(
$args
[
1
],
$options
);
$this
->
_parser
->
bind
(
$args
[
0
],
$options
);
}
/**
* hasRelation
*
* @param string $alias the relation to check if exists
* @return boolean true if the relation exists otherwise false
*/
public
function
hasRelation
(
$alias
)
{
return
$this
->
_parser
->
hasRelation
(
$alias
);
}
/**
* getRelation
*
* @param string $alias relation alias
*/
public
function
getRelation
(
$alias
,
$recursive
=
true
)
{
return
$this
->
_parser
->
getRelation
(
$alias
,
$recursive
);
}
public
function
getRelationParser
()
{
return
$this
->
_parser
;
}
/**
* getRelations
* returns an array containing all relation objects
*
* @return array an array of Doctrine_Relation objects
*/
public
function
getRelations
()
{
return
$this
->
_parser
->
getRelations
();
}
/**
* getBehaviors
* returns all behaviors attached to the class.
...
...
@@ -2059,6 +1950,71 @@ class Doctrine_ClassMetadata implements Doctrine_Configurable, Serializable
}
}
/* The following stuff needs to be touched for the association mapping rewrite */
public
function
bindRelation
(
$args
,
$type
)
{
return
$this
->
bind
(
$args
,
$type
);
}
/**
* @todo Relation mapping rewrite.
*/
public
function
bind
(
$args
,
$type
)
{
$options
=
array
();
$options
[
'type'
]
=
$type
;
if
(
!
isset
(
$args
[
1
]))
{
$args
[
1
]
=
array
();
}
if
(
!
is_array
(
$args
[
1
]))
{
try
{
throw
new
Exception
();
}
catch
(
Exception
$e
)
{
echo
$e
->
getTraceAsString
();
}
}
$options
=
array_merge
(
$args
[
1
],
$options
);
$this
->
_parser
->
bind
(
$args
[
0
],
$options
);
}
/**
* hasRelation
*
* @param string $alias the relation to check if exists
* @return boolean true if the relation exists otherwise false
*/
public
function
hasRelation
(
$alias
)
{
return
$this
->
_parser
->
hasRelation
(
$alias
);
}
/**
* getRelation
*
* @param string $alias relation alias
*/
public
function
getRelation
(
$alias
,
$recursive
=
true
)
{
return
$this
->
_parser
->
getRelation
(
$alias
,
$recursive
);
}
public
function
getRelationParser
()
{
return
$this
->
_parser
;
}
/**
* getRelations
* returns an array containing all relation objects
*
* @return array an array of Doctrine_Relation objects
*/
public
function
getRelations
()
{
return
$this
->
_parser
->
getRelations
();
}
/**
*
...
...
lib/Doctrine/ClassMetadata/Factory.php
View file @
c43f9588
...
...
@@ -130,7 +130,7 @@ class Doctrine_ClassMetadata_Factory
protected
function
_addInheritedFields
(
$subClass
,
$parentClass
)
{
foreach
(
$parentClass
->
get
Column
s
()
as
$name
=>
$definition
)
{
foreach
(
$parentClass
->
get
FieldMapping
s
()
as
$name
=>
$definition
)
{
$fullName
=
"
$name
as "
.
$parentClass
->
getFieldName
(
$name
);
$definition
[
'inherited'
]
=
true
;
$subClass
->
mapColumn
(
...
...
@@ -246,7 +246,7 @@ class Doctrine_ClassMetadata_Factory
case
1
:
// A single identifier is in the mapping
foreach
(
$class
->
getIdentifier
()
as
$pk
)
{
$columnName
=
$class
->
getColumnName
(
$pk
);
$thisColumns
=
$class
->
get
Column
s
();
$thisColumns
=
$class
->
get
FieldMapping
s
();
$e
=
$thisColumns
[
$columnName
];
$found
=
false
;
...
...
lib/Doctrine/Entity.php
View file @
c43f9588
...
...
@@ -342,12 +342,12 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable
$this
->
_data
=
array_merge
(
$this
->
_data
,
$this
->
_id
);
foreach
(
$this
->
_data
as
$k
=>
$v
)
{
if
(
$v
instanceof
Doctrine_Entity
&&
$this
->
_class
->
getTypeOf
(
$k
)
!=
'object'
)
{
if
(
$v
instanceof
Doctrine_Entity
&&
$this
->
_class
->
getTypeOf
Field
(
$k
)
!=
'object'
)
{
unset
(
$vars
[
'_data'
][
$k
]);
}
else
if
(
$v
===
Doctrine_Null
::
$INSTANCE
)
{
unset
(
$vars
[
'_data'
][
$k
]);
}
else
{
switch
(
$this
->
_class
->
getTypeOf
(
$k
))
{
switch
(
$this
->
_class
->
getTypeOf
Field
(
$k
))
{
case
'array'
:
case
'object'
:
$vars
[
'_data'
][
$k
]
=
serialize
(
$vars
[
'_data'
][
$k
]);
...
...
@@ -400,7 +400,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable
$this
->
_class
=
$this
->
_em
->
getClassMetadata
(
$this
->
_entityName
);
foreach
(
$this
->
_data
as
$k
=>
$v
)
{
switch
(
$this
->
_class
->
getTypeOf
(
$k
))
{
switch
(
$this
->
_class
->
getTypeOf
Field
(
$k
))
{
case
'array'
:
case
'object'
:
$this
->
_data
[
$k
]
=
unserialize
(
$this
->
_data
[
$k
]);
...
...
@@ -1024,7 +1024,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable
}
foreach
(
$modifiedFields
as
$field
)
{
$type
=
$this
->
_class
->
getTypeOf
(
$field
);
$type
=
$this
->
_class
->
getTypeOf
Field
(
$field
);
if
(
$this
->
_data
[
$field
]
===
Doctrine_Null
::
$INSTANCE
)
{
$dataSet
[
$field
]
=
null
;
...
...
lib/Doctrine/HydratorNew.php
View file @
c43f9588
...
...
@@ -109,7 +109,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
// Used variables during hydration
reset
(
$this
->
_queryComponents
);
$rootAlias
=
key
(
$this
->
_queryComponents
);
$root
Component
Name
=
$this
->
_queryComponents
[
$rootAlias
][
'metadata'
]
->
getClassName
();
$root
Entity
Name
=
$this
->
_queryComponents
[
$rootAlias
][
'metadata'
]
->
getClassName
();
// if only one class is involved we can make our lives easier
$isSimpleQuery
=
count
(
$this
->
_queryComponents
)
<=
1
;
// Lookup map to quickly discover/lookup existing records in the result
...
...
@@ -128,7 +128,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
if
(
$parserResult
->
isMixedQuery
()
||
$hydrationMode
==
Doctrine
::
HYDRATE_SCALAR
)
{
$result
=
array
();
}
else
{
$result
=
$driver
->
getElementCollection
(
$root
Component
Name
);
$result
=
$driver
->
getElementCollection
(
$root
Entity
Name
);
}
if
(
$stmt
===
false
||
$stmt
===
0
)
{
...
...
@@ -139,7 +139,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
foreach
(
$this
->
_queryComponents
as
$dqlAlias
=>
$component
)
{
// disable lazy-loading of related elements during hydration
$component
[
'metadata'
]
->
setAttribute
(
'loadReferences'
,
false
);
$
component
Name
=
$component
[
'metadata'
]
->
getClassName
();
$
entity
Name
=
$component
[
'metadata'
]
->
getClassName
();
$identifierMap
[
$dqlAlias
]
=
array
();
$resultPointers
[
$dqlAlias
]
=
array
();
$idTemplate
[
$dqlAlias
]
=
''
;
...
...
@@ -163,22 +163,21 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
continue
;
}
// From here on its all about graph construction
// 1) Initialize
$id
=
$idTemplate
;
// initialize the id-memory
$nonemptyComponents
=
array
();
$rowData
=
$this
->
_gatherRowData
(
$data
,
$cache
,
$id
,
$nonemptyComponents
);
//
// hydrate the data of the root entity from the current row
//
$class
=
$this
->
_queryComponents
[
$rootAlias
][
'metadata'
];
$componentName
=
$class
->
getComponentName
();
// 2) Hydrate the data of the root entity from the current row
//$class = $this->_queryComponents[$rootAlias]['metadata'];
//$entityName = $class->getComponentName();
// Check for an existing element
$index
=
false
;
if
(
$isSimpleQuery
||
!
isset
(
$identifierMap
[
$rootAlias
][
$id
[
$rootAlias
]]))
{
$element
=
$driver
->
getElement
(
$rowData
[
$rootAlias
],
$componentName
);
// do we need to index by a custom field?
$element
=
$driver
->
getElement
(
$rowData
[
$rootAlias
],
$rootEntityName
);
if
(
$field
=
$this
->
_getCustomIndexField
(
$rootAlias
))
{
if
(
$parserResult
->
isMixedQuery
())
{
$result
[]
=
array
(
...
...
@@ -198,22 +197,22 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
}
else
{
$index
=
$identifierMap
[
$rootAlias
][
$id
[
$rootAlias
]];
}
$this
->
_
setLastElement
(
$resultPointers
,
$result
,
$index
,
$rootAlias
,
false
);
$this
->
_
updateResultPointer
(
$resultPointers
,
$result
,
$index
,
$rootAlias
,
false
);
unset
(
$rowData
[
$rootAlias
]);
// end hydrate data of the root component for the current row
//
Check for scalar values
//
Extract scalar values. They're appended at the end.
if
(
isset
(
$rowData
[
'scalars'
]))
{
$scalars
=
$rowData
[
'scalars'
];
unset
(
$rowData
[
'scalars'
]);
}
//
now hydrate the rest of the data found in the current row, that belongs to other
//
(related) class
es.
//
3) Now hydrate the rest of the data found in the current row, that
//
belongs to other (related) Entiti
es.
foreach
(
$rowData
as
$dqlAlias
=>
$data
)
{
$index
=
false
;
$map
=
$this
->
_queryComponents
[
$dqlAlias
];
$
component
Name
=
$map
[
'metadata'
]
->
getClassName
();
$
entity
Name
=
$map
[
'metadata'
]
->
getClassName
();
$parent
=
$map
[
'parent'
];
$relation
=
$map
[
'relation'
];
$relationAlias
=
$relation
->
getAlias
();
...
...
@@ -227,7 +226,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
}
else
if
(
isset
(
$resultPointers
[
$parent
]))
{
$baseElement
=&
$resultPointers
[
$parent
];
}
else
{
unset
(
$
prev
[
$dqlAlias
]);
// Ticket #1228
unset
(
$
resultPointers
[
$dqlAlias
]);
// Ticket #1228
continue
;
}
...
...
@@ -241,7 +240,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$index
=
$indexExists
?
$identifierMap
[
$path
][
$id
[
$parent
]][
$id
[
$dqlAlias
]]
:
false
;
$indexIsValid
=
$index
!==
false
?
isset
(
$baseElement
[
$relationAlias
][
$index
])
:
false
;
if
(
!
$indexExists
||
!
$indexIsValid
)
{
$element
=
$driver
->
getElement
(
$data
,
$
component
Name
);
$element
=
$driver
->
getElement
(
$data
,
$
entity
Name
);
if
(
$field
=
$this
->
_getCustomIndexField
(
$dqlAlias
))
{
$driver
->
addRelatedIndexedElement
(
$baseElement
,
$relationAlias
,
$element
,
$field
);
}
else
{
...
...
@@ -252,7 +251,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
}
}
else
if
(
!
isset
(
$baseElement
[
$relationAlias
]))
{
$driver
->
setRelatedElement
(
$baseElement
,
$relationAlias
,
$driver
->
getElementCollection
(
$
component
Name
));
$driver
->
getElementCollection
(
$
entity
Name
));
}
}
else
{
// x-1 relation
...
...
@@ -263,11 +262,11 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
$driver
->
getNullPointer
());
}
else
if
(
!
$driver
->
isFieldSet
(
$baseElement
,
$relationAlias
))
{
$driver
->
setRelatedElement
(
$baseElement
,
$relationAlias
,
$driver
->
getElement
(
$data
,
$
component
Name
));
$driver
->
getElement
(
$data
,
$
entity
Name
));
}
}
if
((
$coll
=&
$driver
->
getReferenceValue
(
$baseElement
,
$relationAlias
))
!==
null
)
{
$this
->
_
setLastElement
(
$resultPointers
,
$coll
,
$index
,
$dqlAlias
,
$oneToOne
);
$this
->
_
updateResultPointer
(
$resultPointers
,
$coll
,
$index
,
$dqlAlias
,
$oneToOne
);
}
}
...
...
@@ -295,27 +294,23 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
}
/**
*
sets the last element of given data array / collection
*
as previous element
*
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.
*
* @param array $
prev The array that contains the pointers to the latest element of each clas
s.
* @param array|Collection
The object collection
.
* @param array $
resultPointers The result pointer
s.
* @param array|Collection
$coll The element
.
* @param boolean|integer $index Index of the element in the collection.
* @param string $dqlAlias
* @param boolean $oneToOne Whether it is a single-valued association or not.
* @return void
* @todo Detailed documentation
*/
protected
function
_
setLastElement
(
&
$resultPointers
,
&
$coll
,
$index
,
$dqlAlias
,
$oneToOne
)
protected
function
_
updateResultPointer
(
&
$resultPointers
,
&
$coll
,
$index
,
$dqlAlias
,
$oneToOne
)
{
if
(
$coll
===
$this
->
_nullObject
||
$coll
===
null
)
{
unset
(
$resultPointers
[
$dqlAlias
]);
// Ticket #1228
return
false
;
return
;
}
if
(
$index
!==
false
)
{
// Link element at $index to previous element for the component
// identified by the DQL alias $alias
$resultPointers
[
$dqlAlias
]
=&
$coll
[
$index
];
return
;
}
...
...
@@ -356,10 +351,12 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
if
(
!
isset
(
$cache
[
$key
]))
{
if
(
$this
->
_isIgnoredName
(
$key
))
continue
;
// cache general information like the column name <-> field name mapping
$e
=
explode
(
'__'
,
$key
);
$columnName
=
strtolower
(
array_pop
(
$e
));
$cache
[
$key
][
'dqlAlias'
]
=
$this
->
_tableAliases
[
strtolower
(
implode
(
'__'
,
$e
))];
// Cache general information like the column name <-> field name mapping
$e
=
explode
(
Doctrine_Query_Production
::
SQLALIAS_SEPARATOR
,
$key
);
$columnName
=
array_pop
(
$e
);
$cache
[
$key
][
'dqlAlias'
]
=
$this
->
_tableAliases
[
implode
(
Doctrine_Query_Production
::
SQLALIAS_SEPARATOR
,
$e
)
];
$classMetadata
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'metadata'
];
// check whether it's an aggregate value or a regular field
if
(
isset
(
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'agg'
][
$columnName
]))
{
...
...
@@ -439,9 +436,11 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract
if
(
$this
->
_isIgnoredName
(
$key
))
continue
;
// cache general information like the column name <-> field name mapping
$e
=
explode
(
'__'
,
$key
);
$columnName
=
strtolower
(
array_pop
(
$e
));
$cache
[
$key
][
'dqlAlias'
]
=
$this
->
_tableAliases
[
strtolower
(
implode
(
'__'
,
$e
))];
$e
=
explode
(
Doctrine_Query_Production
::
SQLALIAS_SEPARATOR
,
$key
);
$columnName
=
array_pop
(
$e
);
$cache
[
$key
][
'dqlAlias'
]
=
$this
->
_tableAliases
[
implode
(
Doctrine_Query_Production
::
SQLALIAS_SEPARATOR
,
$e
)
];
$classMetadata
=
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'metadata'
];
// check whether it's an aggregate value or a regular field
if
(
isset
(
$this
->
_queryComponents
[
$cache
[
$key
][
'dqlAlias'
]][
'agg'
][
$columnName
]))
{
...
...
lib/Doctrine/MappingException.php
0 → 100644
View file @
c43f9588
<?php
/**
* A MappingException indicates that something is wrong with the mapping setup.
*
* @since 2.0
*/
class
Doctrine_MappingException
extends
Doctrine_Exception
{
public
static
function
identifierRequired
(
$entityName
)
{
return
new
self
(
"No identifier specified for Entity '
$entityName
'."
.
" Every Entity must have an identifier."
);
}
}
?>
\ No newline at end of file
lib/Doctrine/Query/Production/PathExpressionEndingWithAsterisk.php
View file @
c43f9588
...
...
@@ -133,7 +133,7 @@ class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrin
}
// Generating the SQL piece
$fields
=
$this
->
_queryComponent
[
'metadata'
]
->
get
MappedColumn
s
();
$fields
=
$this
->
_queryComponent
[
'metadata'
]
->
get
FieldMapping
s
();
$tableAlias
=
$parserResult
->
getTableAliasFromComponentAlias
(
$componentAlias
);
$str
=
''
;
...
...
tests/Orm/Entity/AccessorTest
Case
.php
→
tests/Orm/Entity/AccessorTest.php
View file @
c43f9588
<?php
require_once
'lib/DoctrineTestInit.php'
;
class
Orm_Entity_AccessorTest
Case
extends
Doctrine_OrmTestCase
class
Orm_Entity_AccessorTest
extends
Doctrine_OrmTestCase
{
public
function
testGetterSetterOverride
()
{
$em
=
new
Doctrine_EntityManager
(
new
Doctrine_Connection_Mock
());
$entity1
=
new
CustomAccessorMutatorTestEntity
();
$entity1
->
username
=
'romanb'
;
$this
->
assertEquals
(
'romanb?!'
,
$entity1
->
username
);
...
...
@@ -14,10 +12,14 @@ class Orm_Entity_AccessorTestCase extends Doctrine_OrmTestCase
$entity2
=
new
MagicAccessorMutatorTestEntity
();
$entity2
->
username
=
'romanb'
;
$this
->
assertEquals
(
'romanb?!'
,
$entity1
->
username
);
}
}
/* Local test classes */
class
CustomAccessorMutatorTestEntity
extends
Doctrine_Entity
{
public
static
function
initMetadata
(
$class
)
...
...
tests/Orm/Entity/AllTests.php
View file @
c43f9588
...
...
@@ -6,7 +6,7 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once
'lib/DoctrineTestInit.php'
;
// Tests
require_once
'Orm/Entity/AccessorTest
Case
.php'
;
require_once
'Orm/Entity/AccessorTest.php'
;
require_once
'Orm/Entity/ConstructorTest.php'
;
class
Orm_Entity_AllTests
...
...
@@ -20,7 +20,7 @@ class Orm_Entity_AllTests
{
$suite
=
new
Doctrine_TestSuite
(
'Doctrine Orm Entity Tests'
);
$suite
->
addTestSuite
(
'Orm_Entity_AccessorTest
Case
'
);
$suite
->
addTestSuite
(
'Orm_Entity_AccessorTest'
);
$suite
->
addTestSuite
(
'Orm_Entity_ConstructorTest'
);
return
$suite
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment