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
0f8e9e0b
Commit
0f8e9e0b
authored
Aug 22, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactorings. made basic one-one, one-many joins work.
parent
efca7941
Changes
52
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
617 additions
and
526 deletions
+617
-526
Association.php
lib/Doctrine/Association.php
+1
-0
OneToMany.php
lib/Doctrine/Association/OneToMany.php
+70
-4
Apc.php
lib/Doctrine/Cache/Apc.php
+1
-3
Memcache.php
lib/Doctrine/Cache/Memcache.php
+2
-10
Xcache.php
lib/Doctrine/Cache/Xcache.php
+1
-1
ClassMetadata.php
lib/Doctrine/ClassMetadata.php
+104
-130
Factory.php
lib/Doctrine/ClassMetadata/Factory.php
+12
-9
Collection.php
lib/Doctrine/Collection.php
+20
-10
Connection.php
lib/Doctrine/Connection.php
+1
-1
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+3
-1
Informix.php
lib/Doctrine/DataDict/Informix.php
+2
-1
MySqlPlatform.php
lib/Doctrine/DatabasePlatform/MySqlPlatform.php
+20
-0
Entity.php
lib/Doctrine/Entity.php
+63
-164
EntityManager.php
lib/Doctrine/EntityManager.php
+4
-3
Abstract.php
lib/Doctrine/EntityPersister/Abstract.php
+94
-52
JoinedSubclass.php
lib/Doctrine/EntityPersister/JoinedSubclass.php
+41
-49
Equal.php
lib/Doctrine/Hook/Equal.php
+4
-2
Integer.php
lib/Doctrine/Hook/Integer.php
+4
-2
Parser.php
lib/Doctrine/Hook/Parser.php
+3
-1
Complex.php
lib/Doctrine/Hook/Parser/Complex.php
+4
-2
WordLike.php
lib/Doctrine/Hook/WordLike.php
+4
-2
Join.php
lib/Doctrine/Query/Production/Join.php
+45
-27
JoinVariableDeclaration.php
lib/Doctrine/Query/Production/JoinVariableDeclaration.php
+1
-1
Exception.php
lib/Doctrine/RawSql/Exception.php
+5
-2
Exception.php
lib/Doctrine/Record/Exception.php
+3
-2
Filter.php
lib/Doctrine/Record/Filter.php
+2
-1
Compound.php
lib/Doctrine/Record/Filter/Compound.php
+3
-1
Standard.php
lib/Doctrine/Record/Filter/Standard.php
+2
-1
Generator.php
lib/Doctrine/Record/Generator.php
+2
-1
Iterator.php
lib/Doctrine/Record/Iterator.php
+2
-1
Listener.php
lib/Doctrine/Record/Listener.php
+2
-1
Chain.php
lib/Doctrine/Record/Listener/Chain.php
+3
-2
Interface.php
lib/Doctrine/Record/Listener/Interface.php
+2
-1
Exception.php
lib/Doctrine/Record/State/Exception.php
+3
-2
Relation.php
lib/Doctrine/Relation.php
+2
-1
Association.php
lib/Doctrine/Relation/Association.php
+3
-2
Self.php
lib/Doctrine/Relation/Association/Self.php
+2
-1
ForeignKey.php
lib/Doctrine/Relation/ForeignKey.php
+2
-1
LocalKey.php
lib/Doctrine/Relation/LocalKey.php
+2
-1
Nest.php
lib/Doctrine/Relation/Nest.php
+3
-2
Parser.php
lib/Doctrine/Relation/Parser.php
+2
-1
Exception.php
lib/Doctrine/Relation/Parser/Exception.php
+3
-2
Mysql.php
lib/Doctrine/Sequence/Mysql.php
+1
-1
Sqlite.php
lib/Doctrine/Sequence/Sqlite.php
+1
-1
EntityPersisterTest.php
tests/Orm/EntityPersisterTest.php
+27
-5
SelectSqlGenerationTest.php
tests/Orm/Query/SelectSqlGenerationTest.php
+1
-1
UnitOfWorkTest.php
tests/Orm/UnitOfWorkTest.php
+17
-0
Doctrine_SequenceMock.php
tests/lib/mocks/Doctrine_SequenceMock.php
+5
-0
CmsArticle.php
tests/models/cms/CmsArticle.php
+4
-5
CmsPhonenumber.php
tests/models/cms/CmsPhonenumber.php
+6
-0
CmsUser.php
tests/models/cms/CmsUser.php
+2
-6
ForumUser.php
tests/models/forum/ForumUser.php
+1
-6
No files found.
lib/Doctrine/Association.php
View file @
0f8e9e0b
...
...
@@ -159,6 +159,7 @@ class Doctrine_Association implements Serializable
$this
->
_customAccessor
=
isset
(
$mapping
[
'accessor'
])
?
$mapping
[
'accessor'
]
:
null
;
$this
->
_customMutator
=
isset
(
$mapping
[
'mutator'
])
?
$mapping
[
'mutator'
]
:
null
;
$this
->
_isOptional
=
isset
(
$mapping
[
'isOptional'
])
?
(
bool
)
$mapping
[
'isOptional'
]
:
true
;
$this
->
_cascades
=
isset
(
$mapping
[
'cascade'
])
?
(
array
)
$mapping
[
'cascade'
]
:
array
();
return
$mapping
;
}
...
...
lib/Doctrine/Association/OneToMany.php
View file @
0f8e9e0b
<?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::Mappings;
/**
* Represents a one-to-many mapping.
*
* NOTE: One-to-many mappings can currently not be uni-directional (one -> many).
* They must either be bidirectional (one <-> many) or unidirectional (many -> one).
* In other words, the many-side MUST be the owning side and the one-side MUST be
* the inverse side.
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
* @todo Rename to OneToManyMapping
*/
class
Doctrine_Association_OneToMany
extends
Doctrine_Association
{
/** The target foreign key columns that reference the sourceKeyColumns. */
protected
$_targetForeignKeyColumns
;
/* NOTE: Currently not used because uni-directional one-many not supported atm. */
//protected $_targetForeignKeyColumns;
/** The (typically primary) source key columns that are referenced by the targetForeignKeyColumns. */
protected
$_sourceKeyColumns
;
/* NOTE: Currently not used because uni-directional one-many not supported atm. */
//protected $_sourceKeyColumns;
/** This maps the target foreign key columns to the corresponding (primary) source key columns. */
protected
$_targetForeignKeysToSourceKeys
;
/* NOTE: Currently not used because uni-directional one-many not supported atm. */
//protected $_targetForeignKeysToSourceKeys;
/** This maps the (primary) source key columns to the corresponding target foreign key columns. */
protected
$_sourceKeysToTargetForeignKeys
;
/* NOTE: Currently not used because uni-directional one-many not supported atm. */
//protected $_sourceKeysToTargetForeignKeys;
/** Whether to delete orphaned elements (removed from the collection) */
protected
$_deleteOrphans
=
false
;
/**
* Constructor.
* Creates a new OneToManyMapping.
*
* @param array $mapping The mapping info.
*/
public
function
__construct
(
array
$mapping
)
{
parent
::
__construct
(
$mapping
);
// one side in one-many can currently never be owning side, we may support that later
$this
->
_isOwningSide
=
false
;
}
/**
* Whether orphaned elements (removed from the collection) should be deleted.
*
* @return boolean TRUE if orphaned elements should be deleted, FALSE otherwise.
*/
public
function
shouldDeleteOrphans
()
{
return
$this
->
_deleteOrphans
;
}
/**
* Whether the association is one-to-many.
*
* @return boolean TRUE if the association is one-to-many, FALSE otherwise.
* @override
*/
public
function
isOneToMany
()
{
return
true
;
}
}
?>
\ No newline at end of file
lib/Doctrine/Cache/Apc.php
View file @
0f8e9e0b
...
...
@@ -83,9 +83,7 @@ class Doctrine_Cache_Apc extends Doctrine_Cache_Driver
*/
public
function
save
(
$id
,
$data
,
$lifeTime
=
false
)
{
$lifeTime
=
$this
->
getLifeTime
(
$lifeTime
);
return
(
bool
)
apc_store
(
$id
,
array
(
$data
,
time
()),
$lifeTime
);
return
(
bool
)
apc_store
(
$id
,
$data
,
$lifeTime
);
}
/**
...
...
lib/Doctrine/Cache/Memcache.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Cache_Driver'
);
/**
* Doctrine_Cache_Memcache
*
...
...
@@ -80,15 +80,7 @@ class Doctrine_Cache_Memcache extends Doctrine_Cache_Driver
*/
public
function
fetch
(
$id
,
$testCacheValidity
=
true
)
{
$tmp
=
$this
->
_memcache
->
get
(
$id
);
if
(
is_array
(
$tmp
))
{
return
$tmp
[
0
];
}
else
if
(
is_string
(
$tmp
))
{
return
$tmp
;
}
return
false
;
return
$this
->
_memcache
->
get
(
$id
);
}
/**
...
...
lib/Doctrine/Cache/Xcache.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Cache_Driver'
);
/**
* Doctrine_Cache_Xcache
*
...
...
lib/Doctrine/ClassMetadata.php
View file @
0f8e9e0b
This diff is collapsed.
Click to expand it.
lib/Doctrine/ClassMetadata/Factory.php
View file @
0f8e9e0b
...
...
@@ -31,7 +31,7 @@
* @version $Revision$
* @link www.phpdoctrine.org
* @since 2.0
* @todo Rename to Class
Metadata
Factory.
* @todo Rename to Class
Descriptor
Factory.
*/
class
Doctrine_ClassMetadata_Factory
{
...
...
@@ -114,6 +114,7 @@ class Doctrine_ClassMetadata_Factory
// load metadata of subclasses
// -> child1 -> child2 -> $name
// Move down the hierarchy of parent classes, starting from the topmost class
$parent
=
$class
;
foreach
(
$parentClasses
as
$subclassName
)
{
$subClass
=
new
Doctrine_ClassMetadata
(
$subclassName
,
$this
->
_em
);
...
...
@@ -121,7 +122,7 @@ class Doctrine_ClassMetadata_Factory
$this
->
_addInheritedFields
(
$subClass
,
$parent
);
$this
->
_addInheritedRelations
(
$subClass
,
$parent
);
$this
->
_loadMetadata
(
$subClass
,
$subclassName
);
if
(
$parent
->
getInheritanceType
()
==
Doctrine
::
INHERITANCE_TYPE_SINGLE_TABLE
)
{
if
(
$parent
->
isInheritanceTypeSingleTable
()
)
{
$subClass
->
setTableName
(
$parent
->
getTableName
());
}
$classes
[
$subclassName
]
=
$subClass
;
...
...
@@ -132,15 +133,17 @@ class Doctrine_ClassMetadata_Factory
/**
* Adds inherited fields to the subclass mapping.
*
* @param unknown_type $subClass
* @param unknown_type $parentClass
* @param Doctrine::ORM::Mapping::ClassMetadata $subClass
* @param Doctrine::ORM::Mapping::ClassMetadata $parentClass
* @return void
*/
protected
function
_addInheritedFields
(
$subClass
,
$parentClass
)
{
foreach
(
$parentClass
->
getFieldMappings
()
as
$fieldName
=>
$mapping
)
{
$fullName
=
"
$name
as "
.
$parentClass
->
getFieldName
(
$name
);
$mapping
[
'inherited'
]
=
true
;
$subClass
->
mapField
(
$mapping
);
if
(
!
isset
(
$mapping
[
'inherited'
]))
{
$mapping
[
'inherited'
]
=
$parentClass
->
getClassName
();
}
$subClass
->
addFieldMapping
(
$fieldName
,
$mapping
);
}
}
...
...
@@ -152,8 +155,8 @@ class Doctrine_ClassMetadata_Factory
*/
protected
function
_addInheritedRelations
(
$subClass
,
$parentClass
)
{
foreach
(
$parentClass
->
get
RelationParser
()
->
getRelationDefinitions
()
as
$name
=>
$definition
)
{
$subClass
->
getRelationParser
()
->
addRelationDefinition
(
$name
,
$definition
);
foreach
(
$parentClass
->
get
AssociationMappings
()
as
$fieldName
=>
$mapping
)
{
$subClass
->
addAssociationMapping
(
$name
,
$mapping
);
}
}
...
...
lib/Doctrine/Collection.php
View file @
0f8e9e0b
...
...
@@ -83,7 +83,7 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
*
* @var Doctrine::ORM::Mapping::AssociationMapping
*/
protected
$_association
Mapping
;
protected
$_association
;
/**
* The name of the column that is used for collection key mapping.
...
...
@@ -99,8 +99,6 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
*/
//protected static $null;
protected
$_mapping
;
/**
* The EntityManager.
*
...
...
@@ -261,10 +259,10 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
*
* @return void
*/
public
function
setReference
(
Doctrine_Entity
$entity
,
$relation
)
public
function
setReference
(
Doctrine_Entity
$entity
,
Doctrine_Association
$relation
)
{
$this
->
_owner
=
$entity
;
//$this->relation
= $relation;
$this
->
_association
=
$relation
;
/*if ($relation instanceof Doctrine_Relation_ForeignKey ||
$relation instanceof Doctrine_Relation_LocalKey) {
...
...
@@ -304,6 +302,12 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
$removed
=
$this
->
_data
[
$key
];
unset
(
$this
->
_data
[
$key
]);
//TODO: Register collection as dirty with the UoW if necessary
//$this->_em->getUnitOfWork()->scheduleCollectionUpdate($this);
//TODO: delete entity if shouldDeleteOrphans
/*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) {
$this->_em->delete($removed);
}*/
return
$removed
;
}
...
...
@@ -323,7 +327,7 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
*
* @param string $name
* @since 1.0
* @return
voi
d
* @return
mixe
d
*/
public
function
__unset
(
$key
)
{
...
...
@@ -508,7 +512,7 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
throw
new
Doctrine_Record_Exception
(
'Value variable in set is not an instance of Doctrine_Entity.'
);
}
//
Neither Maps nor Lists allow duplicates, both are Sets
//
TODO: Really prohibit duplicates?
if
(
in_array
(
$value
,
$this
->
_data
,
true
))
{
return
false
;
}
...
...
@@ -956,7 +960,7 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
public
function
mapElements
(
$lambda
)
{
$result
=
array
();
foreach
(
$this
->
_data
as
$key
=>
$entity
)
{
list
(
$key
,
$value
)
=
$lambda
(
$key
,
$entity
);
list
(
$key
,
$value
)
=
each
(
$lambda
(
$key
,
$entity
)
);
$result
[
$key
]
=
$value
;
}
return
$result
;
...
...
@@ -969,14 +973,20 @@ class Doctrine_Collection implements Countable, IteratorAggregate, Serializable,
*/
public
function
clear
()
{
$this
->
_data
=
array
();
//TODO: Register collection as dirty with the UoW if necessary
//TODO: If oneToMany() && shouldDeleteOrphan() delete entities
/*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) {
foreach ($this->_data as $entity) {
$this->_em->delete($entity);
}
}*/
$this
->
_data
=
array
();
}
private
function
_changed
()
{
/*if ( ! $this->_em->getUnitOfWork()->isCollectionScheduledForUpdate($this)) {
$this->_em->getUnitOfWork()->scheduleCollectionUpdate($this);
}*/
}*/
}
}
lib/Doctrine/Connection.php
View file @
0f8e9e0b
...
...
@@ -932,7 +932,7 @@ abstract class Doctrine_Connection
*/
public
function
lastInsertId
(
$table
=
null
,
$field
=
null
)
{
return
$this
->
sequence
->
lastInsertId
(
$table
,
$field
);
return
$this
->
getSequenceManager
()
->
lastInsertId
(
$table
,
$field
);
}
/**
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
0f8e9e0b
...
...
@@ -160,6 +160,8 @@ class Doctrine_Connection_UnitOfWork
foreach
(
$commitOrder
as
$class
)
{
$this
->
_executeInserts
(
$class
);
}
foreach
(
$commitOrder
as
$class
)
{
$this
->
_executeUpdates
(
$class
);
}
...
...
@@ -268,7 +270,7 @@ class Doctrine_Connection_UnitOfWork
}
// add dependency
$otherNode
=
$this
->
_commitOrderCalculator
->
getNodeForKey
(
$targetClassName
);
$
node
->
before
(
$otherN
ode
);
$
otherNode
->
before
(
$n
ode
);
}
}
}
...
...
lib/Doctrine/DataDict/Informix.php
View file @
0f8e9e0b
...
...
@@ -27,7 +27,8 @@
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Revision$
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @todo Remove.
*/
class
Doctrine_DataDict_Informix
extends
Doctrine_DataDict
{
...
...
lib/Doctrine/DatabasePlatform/MySqlPlatform.php
View file @
0f8e9e0b
...
...
@@ -227,6 +227,26 @@ class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
return
'CONCAT('
.
join
(
', '
,
(
array
)
$args
)
.
')'
;
}
/**
* @TEST
*/
public
function
getVarcharDeclaration
(
array
$field
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
if
(
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
getVarcharMaxLength
();
}
else
{
$field
[
'length'
]
=
false
;
}
}
$length
=
(
$field
[
'length'
]
<=
$this
->
getVarcharMaxLength
())
?
$field
[
'length'
]
:
false
;
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
}
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
...
...
lib/Doctrine/Entity.php
View file @
0f8e9e0b
This diff is collapsed.
Click to expand it.
lib/Doctrine/EntityManager.php
View file @
0f8e9e0b
...
...
@@ -44,7 +44,7 @@ class Doctrine_EntityManager
* IMMEDIATE: Flush occurs automatically after each operation that issues database
* queries. No operations are queued.
*/
const
FLUSHMODE_IMMEDIATE
=
'immediate
d
'
;
const
FLUSHMODE_IMMEDIATE
=
'immediate'
;
/**
* AUTO: Flush occurs automatically in the following situations:
* - Before any query executions (to prevent getting stale data)
...
...
@@ -86,7 +86,7 @@ class Doctrine_EntityManager
/**
* The metadata factory, used to retrieve the metadata of entity classes.
*
* @var Doctrine
_ClassMetadata_
Factory
* @var Doctrine
::ORM::Mapping::ClassMetadata
Factory
*/
private
$_metadataFactory
;
...
...
@@ -539,7 +539,8 @@ class Doctrine_EntityManager
}
}
else
{
foreach
(
$data
as
$field
=>
$value
)
{
if
(
!
$entity
->
contains
(
$field
)
||
$entity
->
_internalGetField
(
$field
)
===
null
)
{
$currentValue
=
$entity
->
get
(
$field
);
if
(
!
isset
(
$currentValue
)
||
$entity
->
_internalGetField
(
$field
)
===
null
)
{
$entity
->
_internalSetField
(
$field
,
$value
);
}
}
...
...
lib/Doctrine/EntityPersister/Abstract.php
View file @
0f8e9e0b
...
...
@@ -72,7 +72,7 @@ abstract class Doctrine_EntityPersister_Abstract
private
$_nullObject
;
/**
* Constructs a new
p
ersister.
* Constructs a new
EntityP
ersister.
*/
public
function
__construct
(
Doctrine_EntityManager
$em
,
Doctrine_ClassMetadata
$classMetadata
)
{
...
...
@@ -83,37 +83,78 @@ abstract class Doctrine_EntityPersister_Abstract
$this
->
_nullObject
=
Doctrine_Null
::
$INSTANCE
;
}
/**
* Inserts an entity.
*
* @param Doctrine::ORM::Entity $entity The entity to insert.
* @return void
*/
public
function
insert
(
Doctrine_Entity
$entity
)
{
$insertData
=
array
();
$dataChangeSet
=
$entity
->
_getDataChangeSet
();
$class
=
$entity
->
getClass
();
$referenceChangeSet
=
$entity
->
_getReferenceChangeSet
();
foreach
(
$referenceChangeSet
as
$field
=>
$change
)
{
list
(
$old
,
$new
)
=
each
(
$change
);
$assocMapping
=
$entity
->
getClass
()
->
getAssociationMapping
(
$field
);
if
(
$assocMapping
->
isOneToOne
())
{
if
(
$assocMapping
->
isInverseSide
())
{
//echo "INVERSE!";
continue
;
// ignore inverse side
}
foreach
(
$assocMapping
->
getSourceToTargetKeyColumns
()
as
$localColumn
=>
$foreignColumn
)
{
//echo "$localColumn -- $foreignColumn<br/>";
//$insertData[$localColumn] = 1; //FIX
}
// ... set the foreign key column to the id of the related entity ($new)
$assocMapping
=
$class
->
getAssociationMapping
(
$field
);
if
(
!
$assocMapping
->
isOneToOne
()
||
$assocMapping
->
isInverseSide
())
{
//echo "NOT TO-ONE OR INVERSE!";
continue
;
}
foreach
(
$assocMapping
->
getSourceToTargetKeyColumns
()
as
$sourceColumn
=>
$targetColumn
)
{
//TODO: What if both join columns (local/foreign) are just db-only
// columns (no fields in models) ? Currently we assume the foreign column
// is mapped to a field in the foreign entity.
$insertData
[
$sourceColumn
]
=
$new
->
_internalGetField
(
$new
->
getClass
()
->
getFieldName
(
$targetColumn
)
);
}
//...
}
foreach
(
$dataChangeSet
as
$field
=>
$change
)
{
$insertData
[
$entity
->
getClass
()
->
getColumnName
(
$field
)]
=
current
(
$change
);
}
$this
->
_prepareData
(
$entity
,
$insertData
,
true
);
//TODO: perform insert
$this
->
_conn
->
insert
(
$entity
->
getClass
()
->
getTableName
(),
$insertData
);
$this
->
_conn
->
insert
(
$class
->
getTableName
(),
$insertData
);
//TODO: if IDENTITY pk, assign it
if
(
$class
->
isIdGeneratorIdentity
())
{
//TODO: Postgres IDENTITY columns (SERIAL) use a sequence, so we need to pass the
// sequence name to lastInsertId().
$entity
->
_assignIdentifier
(
$this
->
_conn
->
lastInsertId
());
}
}
/*protected function _fillJoinColumns($entity, array &$data)
{
$referenceChangeSet = $entity->_getReferenceChangeSet();
foreach ($referenceChangeSet as $field => $change) {
list($old, $new) = each($change);
$assocMapping = $entity->getClass()->getAssociationMapping($field);
if ( ! $assocMapping->isOneToOne() || $assocMapping->isInverseSide()) {
//echo "NOT TO-ONE OR INVERSE!";
continue;
}
foreach ($assocMapping->getSourceToTargetKeyColumns() as $sourceColumn => $targetColumn) {
//TODO: What if both join columns (local/foreign) are just db-only
// columns (no fields in models) ? Currently we assume the foreign column
// is mapped to a field in the foreign entity.
$insertData[$sourceColumn] = $new->_internalGetField(
$new->getClass()->getFieldName($targetColumn)
);
}
}
}*/
/**
* Updates an entity.
*
* @param Doctrine::ORM::Entity $entity The entity to update.
* @return void
*/
public
function
update
(
Doctrine_Entity
$entity
)
{
$dataChangeSet
=
$entity
->
_getDataChangeSet
();
...
...
@@ -134,6 +175,12 @@ abstract class Doctrine_EntityPersister_Abstract
//TODO: perform update
}
/**
* Deletes an entity.
*
* @param Doctrine::ORM::Entity $entity The entity to delete.
* @return void
*/
public
function
delete
(
Doctrine_Entity
$entity
)
{
//TODO: perform delete
...
...
@@ -177,6 +224,9 @@ abstract class Doctrine_EntityPersister_Abstract
return
$this
->
_classMetadata
;
}
/**
* @todo Move to ClassMetadata?
*/
public
function
getFieldNames
()
{
if
(
$this
->
_fieldNames
)
{
...
...
@@ -186,6 +236,9 @@ abstract class Doctrine_EntityPersister_Abstract
return
$this
->
_fieldNames
;
}
/**
* @todo Move to ClassMetadata?
*/
public
function
getOwningClass
(
$fieldName
)
{
return
$this
->
_classMetadata
;
...
...
@@ -193,6 +246,7 @@ abstract class Doctrine_EntityPersister_Abstract
/**
* Callback that is invoked during the SQL construction process.
* @todo Move to ClassMetadata?
*/
public
function
getCustomJoins
()
{
...
...
@@ -201,6 +255,7 @@ abstract class Doctrine_EntityPersister_Abstract
/**
* Callback that is invoked during the SQL construction process.
* @todo Move to ClassMetadata?
*/
public
function
getCustomFields
()
{
...
...
@@ -213,7 +268,7 @@ abstract class Doctrine_EntityPersister_Abstract
*
* @return array
*/
protected
function
_convertFieldToColumnNames
(
array
$fields
,
Doctrine_ClassMetadata
$class
)
/*
protected function _convertFieldToColumnNames(array $fields, Doctrine_ClassMetadata $class)
{
$converted = array();
foreach ($fields as $fieldName => $value) {
...
...
@@ -221,65 +276,52 @@ abstract class Doctrine_EntityPersister_Abstract
}
return $converted;
}
}
*/
/**
* Returns an array of modified fields and values with data preparation
* adds column aggregation inheritance and converts Records into primary key values
*
* @param array $array
* @return
array
* @return
void
* @todo Move to EntityPersister. There call _getChangeSet() and apply this logic.
*/
p
ublic
function
prepareData
(
array
$data
=
array
()
)
p
rotected
function
_prepareData
(
$entity
,
array
&
$result
,
$isInsert
=
false
)
{
$dataSet
=
array
();
$modifiedFields
=
$fields
;
foreach
(
$data
as
$field
=>
$value
)
{
$type
=
$this
->
_classMetadata
->
getTypeOfField
(
$field
);
foreach
(
$entity
->
_getDataChangeSet
()
as
$field
=>
$change
)
{
list
(
$oldVal
,
$newVal
)
=
each
(
$change
);
$type
=
$entity
->
getClass
()
->
getTypeOfField
(
$field
);
$columnName
=
$entity
->
getClass
()
->
getColumnName
(
$field
);
if
(
$
value
===
Doctrine_Null
::
$INSTANCE
)
{
$
dataSet
[
$field
]
=
null
;
if
(
$
newVal
===
Doctrine_Null
::
$INSTANCE
)
{
$
result
[
$columnName
]
=
null
;
continue
;
}
switch
(
$type
)
{
case
'array'
:
case
'object'
:
$
dataSet
[
$field
]
=
serialize
(
$value
);
$
result
[
$columnName
]
=
serialize
(
$newVal
);
break
;
case
'gzip'
:
$
dataSet
[
$field
]
=
gzcompress
(
$value
,
5
);
$
result
[
$columnName
]
=
gzcompress
(
$newVal
,
5
);
break
;
case
'boolean'
:
$dataSet
[
$field
]
=
$this
->
_em
->
getConnection
()
->
convertBooleans
(
$value
);
$result
[
$columnName
]
=
$this
->
_em
->
getConnection
()
->
convertBooleans
(
$newVal
);
break
;
case
'enum'
:
$dataSet
[
$field
]
=
$this
->
_class
->
enumIndex
(
$field
,
$value
);
break
;
default
:
$
dataSet
[
$field
]
=
$value
;
$
result
[
$columnName
]
=
$newVal
;
}
}
// @todo cleanup
// populates the discriminator field in Single & Class Table Inheritance
if
(
$this
->
_classMetadata
->
getInheritanceType
()
==
Doctrine_ClassMetadata
::
INHERITANCE_TYPE_JOINED
||
$this
->
_class
->
getInheritanceType
()
==
Doctrine_ClassMetadata
::
INHERITANCE_TYPE_SINGLE_TABLE
)
{
$discCol
=
$this
->
_classMetadata
->
getInheritanceOption
(
'discriminatorColumn'
);
$discMap
=
$this
->
_classMetadata
->
getInheritanceOption
(
'discriminatorMap'
);
$old
=
$this
->
get
(
$discCol
,
false
);
$discValue
=
array_search
(
$this
->
_entityName
,
$discMap
);
if
((
string
)
$old
!==
(
string
)
$discValue
||
$old
===
null
)
{
$dataSet
[
$discCol
]
=
$discValue
;
//$this->_data[$discCol] = $discValue;
}
// @todo Cleanup
// populates the discriminator column on insert in Single & Class Table Inheritance
if
(
$isInsert
&&
(
$entity
->
getClass
()
->
isInheritanceTypeJoined
()
||
$entity
->
getClass
()
->
isInheritanceTypeSingleTable
()))
{
$discColumn
=
$entity
->
getClass
()
->
getInheritanceOption
(
'discriminatorColumn'
);
$discMap
=
$entity
->
getClass
()
->
getInheritanceOption
(
'discriminatorMap'
);
$result
[
$discColumn
]
=
array_search
(
$this
->
_entityName
,
$discMap
);
}
return
$dataSet
;
}
...
...
lib/Doctrine/EntityPersister/JoinedSubclass.php
View file @
0f8e9e0b
...
...
@@ -30,58 +30,53 @@
* @since 2.0
*/
class
Doctrine_EntityPersister_JoinedSubclass
extends
Doctrine_EntityPersister_Abstract
{
//protected $_columnNameFieldNameMap = array();
{
/**
* Inserts an entity that is part of a Class Table Inheritance hierarchy.
*
* @param Doctrine_Entity $record record to be inserted
* @return boolean
* @override
*/
p
rotected
function
_doInsert
(
Doctrine_Entity
$record
)
p
ublic
function
insert
(
Doctrine_Entity
$entity
)
{
$class
=
$this
->
_classMetadata
;
$conn
=
$this
->
_conn
;
$dataSet
=
$this
->
_groupFieldsByDefiningClass
(
$record
);
$class
=
$entity
->
getClass
();
$dataSet
=
array
();
$this
->
_prepareData
(
$entity
,
$dataSet
,
true
);
$dataSet
=
$this
->
_groupFieldsByDefiningClass
(
$class
,
$dataSet
);
$component
=
$class
->
getClassName
();
$classes
=
$class
->
getParentClasses
();
array_unshift
(
$classes
,
$component
);
try
{
$conn
->
beginInternalTransaction
();
$identifier
=
null
;
foreach
(
array_reverse
(
$classes
)
as
$k
=>
$parent
)
{
$parentClass
=
$conn
->
getClassMetadata
(
$parent
);
if
(
$k
==
0
)
{
$identifierType
=
$parentClass
->
getIdentifierType
();
if
(
$identifierType
==
Doctrine
::
IDENTIFIER_AUTOINC
)
{
$identifier
=
null
;
foreach
(
array_reverse
(
$classes
)
as
$k
=>
$parent
)
{
$parentClass
=
$this
->
_em
->
getClassMetadata
(
$parent
);
if
(
$k
==
0
)
{
if
(
$parentClass
->
isIdGeneratorIdentity
())
{
$this
->
_insertRow
(
$parentClass
->
getTableName
(),
$dataSet
[
$parent
]);
$identifier
=
$this
->
_conn
->
lastInsertId
();
}
else
if
(
$parentClass
->
isIdGeneratorSequence
())
{
$seq
=
$entity
->
getClassMetadata
()
->
getTableOption
(
'sequenceName'
);
if
(
!
empty
(
$seq
))
{
$id
=
$this
->
_conn
->
getSequenceManager
()
->
nextId
(
$seq
);
$identifierFields
=
$parentClass
->
getIdentifier
();
$dataSet
[
$parent
][
$identifierFields
[
0
]]
=
$id
;
$this
->
_insertRow
(
$parentClass
->
getTableName
(),
$dataSet
[
$parent
]);
$identifier
=
$conn
->
sequence
->
lastInsertId
();
}
else
if
(
$identifierType
==
Doctrine
::
IDENTIFIER_SEQUENCE
)
{
$seq
=
$record
->
getClassMetadata
()
->
getTableOption
(
'sequenceName'
);
if
(
!
empty
(
$seq
))
{
$id
=
$conn
->
sequence
->
nextId
(
$seq
);
$identifierFields
=
(
array
)
$parentClass
->
getIdentifier
();
$dataSet
[
$parent
][
$identifierFields
[
0
]]
=
$id
;
$this
->
_insertRow
(
$parentClass
->
getTableName
(),
$dataSet
[
$parent
]);
}
}
else
{
throw
new
Doctrine_Mapper_Exception
(
"Unsupported identifier type '
$identifierType
'."
);
}
$record
->
assignIdentifier
(
$identifier
);
}
else
{
foreach
((
array
)
$record
->
identifier
()
as
$id
=>
$value
)
{
$dataSet
[
$parent
][
$parentClass
->
getColumnName
(
$id
)]
=
$value
;
}
$this
->
_insertRow
(
$parentClass
->
getTableName
(),
$dataSet
[
$parent
]);
throw
new
Doctrine_Mapper_Exception
(
"Unsupported identifier type '
$identifierType
'."
);
}
$entity
->
_assignIdentifier
(
$identifier
);
}
else
{
foreach
(
$entity
->
_identifier
()
as
$id
=>
$value
)
{
$dataSet
[
$parent
][
$parentClass
->
getColumnName
(
$id
)]
=
$value
;
}
$this
->
_insertRow
(
$parentClass
->
getTableName
(),
$dataSet
[
$parent
]);
}
$conn
->
commit
();
}
catch
(
Exception
$e
)
{
$conn
->
rollback
();
throw
$e
;
}
return
true
;
...
...
@@ -255,29 +250,26 @@ class Doctrine_EntityPersister_JoinedSubclass extends Doctrine_EntityPersister_A
*
* @return array
*/
protected
function
_groupFieldsByDefiningClass
(
Doctrine_
Entity
$record
)
protected
function
_groupFieldsByDefiningClass
(
Doctrine_
ClassMetadata
$class
,
array
$fields
)
{
$conn
=
$this
->
_conn
;
$classMetadata
=
$this
->
_classMetadata
;
$dataSet
=
array
();
$component
=
$classMetadata
->
getClassName
();
$array
=
$record
->
getPrepared
();
$component
=
$class
->
getClassName
();
$classes
=
array_merge
(
array
(
$component
),
$class
Metadata
->
getParentClasses
());
$classes
=
array_merge
(
array
(
$component
),
$class
->
getParentClasses
());
foreach
(
$classes
as
$class
)
{
$dataSet
[
$class
]
=
array
();
$parentClassMetadata
=
$
conn
->
getClassMetadata
(
$class
);
foreach
(
$parentClassMetadata
->
get
Columns
()
as
$columnName
=>
$definition
)
{
if
((
isset
(
$
definition
[
'primary'
])
&&
$definition
[
'primary
'
]
===
true
)
||
(
isset
(
$
definition
[
'inherited'
])
&&
$definition
[
'inherited'
]
===
true
))
{
$parentClassMetadata
=
$
this
->
_em
->
getClassMetadata
(
$class
);
foreach
(
$parentClassMetadata
->
get
FieldMappings
()
as
$fieldName
=>
$mapping
)
{
if
((
isset
(
$
mapping
[
'id'
])
&&
$mapping
[
'id
'
]
===
true
)
||
(
isset
(
$
mapping
[
'inherited'
])
&&
$mapping
[
'inherited'
]
===
true
))
{
continue
;
}
$fieldName
=
$classMetadata
->
getFieldName
(
$columnName
);
if
(
!
array_key_exists
(
$fieldName
,
$array
))
{
if
(
!
array_key_exists
(
$fieldName
,
$fields
))
{
continue
;
}
$dataSet
[
$class
][
$columnName
]
=
$array
[
$fieldName
];
$columnName
=
$parentClassMetadata
->
getColumnName
(
$fieldName
);
$dataSet
[
$class
][
$columnName
]
=
$fields
[
$fieldName
];
}
}
...
...
lib/Doctrine/Hook/Equal.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Hook_Parser'
);
/**
* Doctrine_Hook_Equal
*
...
...
@@ -28,7 +28,9 @@ Doctrine::autoload('Doctrine_Hook_Parser');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Can be removed?
* @deprecated
*/
class
Doctrine_Hook_Equal
extends
Doctrine_Hook_Parser
{
...
...
lib/Doctrine/Hook/Integer.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Hook_Parser_Complex'
);
/**
* Doctrine_Hook_Integer
*
...
...
@@ -28,7 +28,9 @@ Doctrine::autoload('Doctrine_Hook_Parser_Complex');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Can be removed?
* @deprecated
*/
class
Doctrine_Hook_Integer
extends
Doctrine_Hook_Parser_Complex
{
...
...
lib/Doctrine/Hook/Parser.php
View file @
0f8e9e0b
...
...
@@ -28,7 +28,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 Can be removed?
* @deprecated
*/
abstract
class
Doctrine_Hook_Parser
{
...
...
lib/Doctrine/Hook/Parser/Complex.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Hook_Parser'
);
/**
* Doctrine_Hook_Parser_Complex
*
...
...
@@ -28,7 +28,9 @@ Doctrine::autoload('Doctrine_Hook_Parser');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Can be removed?
* @deprecated
*/
abstract
class
Doctrine_Hook_Parser_Complex
extends
Doctrine_Hook_Parser
{
...
...
lib/Doctrine/Hook/WordLike.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Hook_Parser'
);
/**
* Doctrine_Hook_WordLike
*
...
...
@@ -28,7 +28,9 @@ Doctrine::autoload('Doctrine_Hook_Parser');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
* @todo Can be removed?
*/
class
Doctrine_Hook_WordLike
extends
Doctrine_Hook_Parser_Complex
{
...
...
lib/Doctrine/Query/Production/Join.php
View file @
0f8e9e0b
...
...
@@ -88,33 +88,51 @@ class Doctrine_Query_Production_Join extends Doctrine_Query_Production
return
$sql
.
' ON '
.
$conditionExpression
;
}
// We need to build the relationship conditions. Retrieving AssociationMapping
$queryComponent
=
$this
->
_rangeVariableDeclaration
->
getQueryComponent
();
$relationColumns
=
$queryComponent
[
'relation'
]
->
getSourceToTargetKeyColumns
();
$relationConditionExpression
=
''
;
// We have an array('localColumn' => 'foreignColumn', ...) here
foreach
(
$relationColumns
as
$localColumn
=>
$foreignColumn
)
{
// leftExpression = rightExpression
// Defining leftExpression
$leftExpression
=
$conn
->
quoteIdentifier
(
$parserResult
->
getTableAliasFromComponentAlias
(
$queryComponent
[
'parent'
])
.
'.'
.
$localColumn
);
// Defining rightExpression
$rightExpression
=
$conn
->
quoteIdentifier
(
$parserResult
->
getTableAliasFromComponentAlias
(
$this
->
_rangeVariableDeclaration
->
getIdentificationVariable
()
)
.
'.'
.
$foreignColumn
);
// Building the relation
$relationConditionExpression
.=
((
$relationConditionExpression
!=
''
)
?
' AND '
:
''
)
.
$leftExpression
.
' = '
.
$rightExpression
;
}
return
$sql
.
' ON '
.
$relationConditionExpression
.
' AND ('
.
$conditionExpression
.
')'
;
// We need to build the join conditions. Retrieving AssociationMapping
$queryComponent
=
$this
->
_rangeVariableDeclaration
->
getQueryComponent
();
$association
=
$queryComponent
[
'relation'
];
$joinColumns
=
array
();
if
(
$association
->
isOneToMany
()
||
$association
->
isOneToOne
())
{
if
(
$association
->
isInverseSide
())
{
// joinColumns are found on the other (owning) side
$targetClass
=
$this
->
_em
->
getClassMetadata
(
$association
->
getTargetEntityName
());
$joinColumns
=
$targetClass
->
getAssociationMapping
(
$association
->
getMappedByFieldName
())
->
getTargetToSourceKeyColumns
();
}
else
{
$joinColumns
=
$association
->
getSourceToTargetKeyColumns
();
}
}
else
{
//TODO: many-many
}
$relationConditionExpression
=
''
;
// We have an array('localColumn' => 'foreignColumn', ...) here
foreach
(
$joinColumns
as
$localColumn
=>
$foreignColumn
)
{
// leftExpression = rightExpression
// Defining leftExpression
$leftExpression
=
$conn
->
quoteIdentifier
(
$parserResult
->
getTableAliasFromComponentAlias
(
$queryComponent
[
'parent'
])
.
'.'
.
$localColumn
);
// Defining rightExpression
$rightExpression
=
$conn
->
quoteIdentifier
(
$parserResult
->
getTableAliasFromComponentAlias
(
$this
->
_rangeVariableDeclaration
->
getIdentificationVariable
()
)
.
'.'
.
$foreignColumn
);
// Building the relation
$relationConditionExpression
.=
((
$relationConditionExpression
!=
''
)
?
' AND '
:
''
)
.
$leftExpression
.
' = '
.
$rightExpression
;
}
$sql
.=
' ON '
.
$relationConditionExpression
;
$sql
.=
empty
(
$conditionExpression
)
?
''
:
' AND ('
.
$conditionExpression
.
')'
;
return
$sql
;
}
...
...
lib/Doctrine/Query/Production/JoinVariableDeclaration.php
View file @
0f8e9e0b
...
...
@@ -52,7 +52,7 @@ class Doctrine_Query_Production_JoinVariableDeclaration extends Doctrine_Query_P
public
function
buildSql
()
{
return
$this
->
_join
->
buildSql
()
.
' '
.
(
isset
(
$this
->
_indexby
)
?
$this
->
_indexby
->
buildSql
()
.
' '
:
''
);
return
$this
->
_join
->
buildSql
()
.
(
isset
(
$this
->
_indexby
)
?
$this
->
_indexby
->
buildSql
()
.
' '
:
''
);
}
...
...
lib/Doctrine/RawSql/Exception.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,9 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Exception'
);
#namespace Doctrine::ORM::Exceptions;
/**
* Doctrine_RawSql_Exception
*
...
...
@@ -28,7 +30,8 @@ Doctrine::autoload('Doctrine_Exception');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Rename to NativeSqlException or maybe remove.
*/
class
Doctrine_RawSql_Exception
extends
Doctrine_Exception
{
}
\ No newline at end of file
lib/Doctrine/Record/Exception.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Exception'
);
/**
* Doctrine_Exception
*
...
...
@@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Exception');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated Remove.
*/
class
Doctrine_Record_Exception
extends
Doctrine_Exception
{
}
\ No newline at end of file
lib/Doctrine/Record/Filter.php
View file @
0f8e9e0b
...
...
@@ -29,7 +29,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1298 $
* @version $Revision: 1298 $
* @deprecated Remove.
*/
abstract
class
Doctrine_Record_Filter
{
...
...
lib/Doctrine/Record/Filter/Compound.php
View file @
0f8e9e0b
...
...
@@ -28,7 +28,9 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1298 $
* @version $Revision: 1298 $
* @todo Remove.
* @deprecated
*/
class
Doctrine_Record_Filter_Compound
extends
Doctrine_Record_Filter
{
...
...
lib/Doctrine/Record/Filter/Standard.php
View file @
0f8e9e0b
...
...
@@ -29,7 +29,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1298 $
* @version $Revision: 1298 $
* @deprecated Remove.
*/
class
Doctrine_Record_Filter_Standard
extends
Doctrine_Record_Filter
{
...
...
lib/Doctrine/Record/Generator.php
View file @
0f8e9e0b
...
...
@@ -28,7 +28,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision$
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @todo Rename. Move. Reimpl?
*/
abstract
class
Doctrine_Record_Generator
{
...
...
lib/Doctrine/Record/Iterator.php
View file @
0f8e9e0b
...
...
@@ -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$
* @deprecated Remove.
*/
class
Doctrine_Record_Iterator
extends
ArrayIterator
{
...
...
lib/Doctrine/Record/Listener.php
View file @
0f8e9e0b
...
...
@@ -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$
* @deprecated Remove.
*/
class
Doctrine_Record_Listener
implements
Doctrine_Record_Listener_Interface
{
...
...
lib/Doctrine/Record/Listener/Chain.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,6 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Access'
);
/**
* Doctrine_Record_Listener_Chain
...
...
@@ -31,7 +30,9 @@ Doctrine::autoload('Doctrine_Access');
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
* @todo Remove
*/
class
Doctrine_Record_Listener_Chain
extends
Doctrine_Access
implements
Doctrine_Record_Listener_Interface
{
...
...
lib/Doctrine/Record/Listener/Interface.php
View file @
0f8e9e0b
...
...
@@ -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$
* @deprecated Remove.
*/
interface
Doctrine_Record_Listener_Interface
{
...
...
lib/Doctrine/Record/State/Exception.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Record_Exception'
);
/**
* Doctrine_Exception
*
...
...
@@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Record_Exception');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Deprecated. Remove
*/
class
Doctrine_Record_State_Exception
extends
Doctrine_Record_Exception
{
}
\ No newline at end of file
lib/Doctrine/Relation.php
View file @
0f8e9e0b
...
...
@@ -29,7 +29,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
abstract
class
Doctrine_Relation
implements
ArrayAccess
{
...
...
lib/Doctrine/Relation/Association.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Relation'
);
/**
* Doctrine_Relation_Association
*
...
...
@@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Relation');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class
Doctrine_Relation_Association
extends
Doctrine_Relation
{
...
...
lib/Doctrine/Relation/Association/Self.php
View file @
0f8e9e0b
...
...
@@ -28,7 +28,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class
Doctrine_Relation_Association_Self
extends
Doctrine_Relation_Association
{
...
...
lib/Doctrine/Relation/ForeignKey.php
View file @
0f8e9e0b
...
...
@@ -29,7 +29,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
*/
class
Doctrine_Relation_ForeignKey
extends
Doctrine_Relation
{
...
...
lib/Doctrine/Relation/LocalKey.php
View file @
0f8e9e0b
...
...
@@ -29,7 +29,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
*/
class
Doctrine_Relation_LocalKey
extends
Doctrine_Relation
{
...
...
lib/Doctrine/Relation/Nest.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Relation_Association'
);
/**
* Doctrine_Relation_Association_Self
*
...
...
@@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Relation_Association');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1434 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class
Doctrine_Relation_Nest
extends
Doctrine_Relation_Association
{
...
...
lib/Doctrine/Relation/Parser.php
View file @
0f8e9e0b
...
...
@@ -30,7 +30,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @todo Composite key support?
* @todo Remove. Association mapping needs a reimplementation.
* @todo Remove. Association mapping is being reimplemented.
* @deprecated
*/
class
Doctrine_Relation_Parser
{
...
...
lib/Doctrine/Relation/Parser/Exception.php
View file @
0f8e9e0b
...
...
@@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine
::
autoload
(
'Doctrine_Relation_Exception'
);
/**
* Doctrine_Relation_Parser_Exception
*
...
...
@@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Relation_Exception');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated Remove.
*/
class
Doctrine_Relation_Parser_Exception
extends
Doctrine_Relation_Exception
{
}
\ No newline at end of file
lib/Doctrine/Sequence/Mysql.php
View file @
0f8e9e0b
...
...
@@ -83,7 +83,7 @@ class Doctrine_Sequence_Mysql extends Doctrine_Sequence
*/
public
function
lastInsertId
(
$table
=
null
,
$field
=
null
)
{
return
$this
->
conn
->
get
Dbh
()
->
lastInsertId
();
return
$this
->
conn
->
get
Pdo
()
->
lastInsertId
();
}
/**
...
...
lib/Doctrine/Sequence/Sqlite.php
View file @
0f8e9e0b
...
...
@@ -84,7 +84,7 @@ class Doctrine_Sequence_Sqlite extends Doctrine_Sequence
*/
public
function
lastInsertId
(
$table
=
null
,
$field
=
null
)
{
return
$this
->
conn
->
get
Dbh
()
->
lastInsertId
();
return
$this
->
conn
->
get
Pdo
()
->
lastInsertId
();
}
/**
...
...
tests/Orm/EntityPersisterTest.php
View file @
0f8e9e0b
...
...
@@ -11,32 +11,54 @@ class Orm_EntityPersisterTest extends Doctrine_OrmTestCase
private
$_persister
;
// SUT
private
$_connMock
;
private
$_emMock
;
private
$_seqManagerMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
_connMock
=
new
Doctrine_ConnectionMock
(
array
());
$this
->
_emMock
=
new
Doctrine_EntityManagerMock
(
$this
->
_connMock
);
$this
->
_seqManagerMock
=
new
Doctrine_SequenceMock
(
$this
->
_connMock
);
$this
->
_connMock
->
setDatabasePlatform
(
new
Doctrine_DatabasePlatformMock
());
$this
->
_connMock
->
setSequenceManager
(
$this
->
_seqManagerMock
);
$this
->
_persister
=
new
Doctrine_EntityPersister_Standard
(
$this
->
_emMock
,
$this
->
_emMock
->
getClassMetadata
(
"ForumUser"
));
}
public
function
test
Tes
t
()
{
public
function
test
Inser
t
()
{
$user
=
new
ForumUser
();
$user
->
username
=
"romanb"
;
$user
->
avatar
=
new
ForumAvatar
();
$this
->
_persister
->
insert
(
$user
);
$this
->
_seqManagerMock
->
autoinc
();
//fake identity column autoinc
$this
->
_persister
->
insert
(
$user
->
avatar
);
$inserts
=
$this
->
_connMock
->
getInserts
();
//check
$this
->
assertEquals
(
1
,
count
(
$inserts
));
$this
->
assertEquals
(
0
,
$user
->
avatar
->
id
);
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_avatar'
]));
$this
->
assertEquals
(
1
,
count
(
$inserts
[
'forum_avatar'
]));
$this
->
assertTrue
(
empty
(
$inserts
[
'forum_avatar'
][
0
]));
$this
->
_seqManagerMock
->
autoinc
();
//fake identity column autoinc
$this
->
_persister
->
insert
(
$user
);
$inserts
=
$this
->
_connMock
->
getInserts
();
//var_dump($inserts);
//check
$this
->
assertEquals
(
2
,
count
(
$inserts
));
$this
->
assertEquals
(
1
,
$user
->
id
);
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_user'
]));
$this
->
assertEquals
(
1
,
count
(
$inserts
[
'forum_user'
]));
$this
->
assertEquals
(
1
,
count
(
$inserts
[
'forum_user'
][
0
]));
$this
->
assertEquals
(
3
,
count
(
$inserts
[
'forum_user'
][
0
]));
//username column
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_user'
][
0
][
'username'
]));
$this
->
assertEquals
(
'romanb'
,
$inserts
[
'forum_user'
][
0
][
'username'
]);
//avatar_id join column
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_user'
][
0
][
'avatar_id'
]));
$this
->
assertEquals
(
0
,
$inserts
[
'forum_user'
][
0
][
'avatar_id'
]);
//dtype discriminator column
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_user'
][
0
][
'dtype'
]));
$this
->
assertEquals
(
'user'
,
$inserts
[
'forum_user'
][
0
][
'dtype'
]);
}
}
\ No newline at end of file
tests/Orm/Query/SelectSqlGenerationTest.php
View file @
0f8e9e0b
...
...
@@ -172,7 +172,7 @@ class Orm_Query_SelectSqlGenerationTest extends Doctrine_OrmTestCase
{
$this
->
assertSqlGeneration
(
'SELECT u.id, a.id FROM CmsUser u LEFT JOIN u.articles a'
,
'SELECT cu.id AS cu__id, ca.id AS ca__id FROM cms_user cu LEFT JOIN cms_article ca ON c
a.user_id = cu.
id WHERE 1 = 1'
'SELECT cu.id AS cu__id, ca.id AS ca__id FROM cms_user cu LEFT JOIN cms_article ca ON c
u.id = ca.user_
id WHERE 1 = 1'
);
}
...
...
tests/Orm/UnitOfWorkTest.php
View file @
0f8e9e0b
...
...
@@ -126,6 +126,23 @@ class Orm_UnitOfWorkTest extends Doctrine_OrmTestCase
$this
->
assertEquals
(
0
,
count
(
$this
->
_persisterMock
->
getDeletes
()));
}
public
function
testCommitOrder
()
{
$avatar
=
new
ForumAvatar
();
$this
->
_user
->
avatar
=
$avatar
;
$this
->
_unitOfWork
->
save
(
$this
->
_user
);
// save cascaded to avatar
$this
->
assertEquals
(
2
,
count
(
$this
->
_persisterMock
->
getInserts
()));
// insert forced
$this
->
assertEquals
(
0
,
count
(
$this
->
_persisterMock
->
getUpdates
()));
$this
->
assertEquals
(
0
,
count
(
$this
->
_persisterMock
->
getDeletes
()));
// verify order of inserts()s
$inserts
=
$this
->
_persisterMock
->
getInserts
();
$this
->
assertSame
(
$avatar
,
$inserts
[
0
]);
$this
->
assertSame
(
$this
->
_user
,
$inserts
[
1
]);
//...
}
public
function
testSavingSingleEntityWithSequenceIdGeneratorSchedulesInsert
()
{
//...
...
...
tests/lib/mocks/Doctrine_SequenceMock.php
View file @
0f8e9e0b
...
...
@@ -34,6 +34,11 @@ class Doctrine_SequenceMock extends Doctrine_Sequence
{
$this
->
_sequenceNumber
=
0
;
}
public
function
autoinc
()
{
$this
->
_sequenceNumber
++
;
}
}
?>
\ No newline at end of file
tests/models/cms/CmsArticle.php
View file @
0f8e9e0b
...
...
@@ -35,17 +35,16 @@ class CmsArticle extends Doctrine_Entity
'length'
=>
4
));
/*$mapping->hasMany('CmsComment as comments', array(
'local' => 'id', 'foreign' => 'article_id'));*/
$mapping
->
mapOneToMany
(
array
(
'fieldName'
=>
'comments'
,
'targetEntity'
=>
'CmsComment'
,
));
/*$mapping->mapManyToOne(array(
'fieldName' => 'author',
$mapping
->
mapManyToOne
(
array
(
'fieldName'
=>
'user'
,
'targetEntity'
=>
'CmsUser'
,
'joinColumns'
=>
array
(
'user_id'
=>
'id'
)
));
*/
));
}
}
tests/models/cms/CmsPhonenumber.php
View file @
0f8e9e0b
...
...
@@ -17,5 +17,11 @@ class CmsPhonenumber extends Doctrine_Entity
'length'
=>
50
,
'id'
=>
true
));
$mapping
->
mapManyToOne
(
array
(
'fieldName'
=>
'user'
,
'targetEntity'
=>
'CmsUser'
,
'joinColumns'
=>
array
(
'user_id'
=>
'id'
)
));
}
}
tests/models/cms/CmsUser.php
View file @
0f8e9e0b
...
...
@@ -35,21 +35,17 @@ class CmsUser extends Doctrine_Entity
'type'
=>
'string'
,
'length'
=>
255
));
/*$mapping->hasMany('CmsPhonenumber as phonenumbers', array(
'local' => 'id', 'foreign' => 'user_id'));
$mapping->hasMany('CmsArticle as articles', array(
'local' => 'id', 'foreign' => 'user_id'));*/
$mapping
->
mapOneToMany
(
array
(
'fieldName'
=>
'phonenumbers'
,
'targetEntity'
=>
'CmsPhonenumber'
,
'mappedBy'
=>
'user'
));
$mapping
->
mapOneToMany
(
array
(
'fieldName'
=>
'articles'
,
'targetEntity'
=>
'CmsArticle'
,
'mappedBy'
=>
'user'
));
}
...
...
tests/models/forum/ForumUser.php
View file @
0f8e9e0b
...
...
@@ -21,12 +21,6 @@ class ForumUser extends Doctrine_Entity
));
// register subclasses
$mapping
->
setSubclasses
(
array
(
'ForumAdministrator'
));
// the discriminator column
$mapping
->
mapField
(
array
(
'fieldName'
=>
'dtype'
,
'type'
=>
'string'
,
'length'
=>
50
));
// column-to-field mapping
$mapping
->
mapField
(
array
(
...
...
@@ -46,6 +40,7 @@ class ForumUser extends Doctrine_Entity
'fieldName'
=>
'avatar'
,
'targetEntity'
=>
'ForumAvatar'
,
'joinColumns'
=>
array
(
'avatar_id'
=>
'id'
),
'cascade'
=>
array
(
'save'
)
));
}
...
...
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