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
599dc759
Commit
599dc759
authored
Oct 20, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #180
parent
20f50425
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
17 deletions
+93
-17
Connection.php
lib/Doctrine/Connection.php
+4
-4
Record.php
lib/Doctrine/Record.php
+13
-3
Table.php
lib/Doctrine/Table.php
+7
-7
RelationTestCase.php
tests/RelationTestCase.php
+67
-1
run.php
tests/run.php
+2
-2
No files found.
lib/Doctrine/Connection.php
View file @
599dc759
...
...
@@ -540,7 +540,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this
->
table
->
getConnection
()
->
execute
(
$query
,
array
(
$r
->
getIncremented
(),
$record
->
getIncremented
()));
}
$operations
=
Doctrine_Relation
::
getInsertOperations
(
$
this
->
originals
[
$alias
]
,
$new
);
$operations
=
Doctrine_Relation
::
getInsertOperations
(
$
record
->
obtainOriginals
(
$alias
)
,
$new
);
foreach
(
$operations
as
$r
)
{
$reldao
=
$asf
->
create
();
$reldao
->
set
(
$fk
->
getForeign
(),
$r
);
...
...
@@ -548,14 +548,14 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$reldao
->
save
();
}
$this
->
originals
[
$alias
]
=
clone
$this
->
references
[
$alias
]
;
$record
->
assignOriginals
(
$alias
,
clone
$this
->
references
[
$alias
])
;
}
}
elseif
(
$fk
instanceof
Doctrine_Relation_ForeignKey
||
$fk
instanceof
Doctrine_Relation_LocalKey
)
{
if
(
$fk
->
isOneToOne
())
{
if
(
isset
(
$this
->
originals
[
$alias
])
&&
$this
->
originals
[
$alias
]
->
obtainIdentifier
()
!=
$this
->
references
[
$alias
]
->
obtainIdentifier
())
$
this
->
originals
[
$alias
]
->
delete
();
if
(
$record
->
obtainOriginals
(
$alias
)
&&
$record
->
obtainOriginals
(
$alias
)
->
obtainIdentifier
()
!=
$this
->
references
[
$alias
]
->
obtainIdentifier
())
$
record
->
obtainOriginals
(
$alias
)
->
delete
();
}
else
{
if
(
isset
(
$this
->
references
[
$alias
]))
{
$new
=
$this
->
references
[
$alias
];
...
...
lib/Doctrine/Record.php
View file @
599dc759
...
...
@@ -434,7 +434,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$vars
=
get_object_vars
(
$this
);
unset
(
$vars
[
'references'
]);
unset
(
$vars
[
'collections'
]);
unset
(
$vars
[
'originals'
]);
unset
(
$vars
[
'_table'
]);
...
...
@@ -638,7 +637,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
// check if the property is null (= it is the Doctrine_Null object located in self::$null)
if
(
$this
->
_data
[
$lower
]
===
self
::
$null
)
$this
->
load
();
if
(
$this
->
_data
[
$lower
]
===
self
::
$null
)
$value
=
null
;
...
...
@@ -854,12 +853,15 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return
$a
;
}
/**
* getPrepared
*
* 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
*/
final
public
function
getPrepared
(
array
$array
=
array
())
{
public
function
getPrepared
(
array
$array
=
array
())
{
$a
=
array
();
if
(
empty
(
$array
))
...
...
@@ -968,6 +970,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
getIterator
()
{
return
new
Doctrine_Record_Iterator
(
$this
);
}
public
function
obtainOriginals
(
$name
)
{
if
(
isset
(
$this
->
originals
[
$name
]))
return
$this
->
originals
[
$name
];
return
false
;
}
/**
* saveAssociations
*
...
...
lib/Doctrine/Table.php
View file @
599dc759
...
...
@@ -89,7 +89,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
/**
* @var array $columns an array of column definitions
*/
private
$columns
;
private
$columns
=
array
()
;
/**
* @var array $bound bound relations
*/
...
...
@@ -103,8 +103,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* determining its state
*/
private
$columnCount
;
/**
* @var array $inheritanceMap inheritanceMap is used for inheritance mapping, keys representing columns and values
* the column values that should correspond to child classes
...
...
@@ -229,7 +227,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
}
}
else
{
throw
new
Doctrine_Exception
(
"Class '
$name
' has no table definition."
);
throw
new
Doctrine_
Table_
Exception
(
"Class '
$name
' has no table definition."
);
}
...
...
@@ -589,7 +587,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$original
=
$name
;
if
(
isset
(
$this
->
relations
[
$name
]))
return
$this
->
relations
[
$name
];
return
$this
->
relations
[
$name
];
if
(
isset
(
$this
->
bound
[
$name
]))
{
$type
=
$this
->
bound
[
$name
][
1
];
...
...
@@ -612,8 +610,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
}
else
throw
new
Doctrine_Table_Exception
(
"Only one-to-one relations are possible when local reference key is used."
);
}
elseif
(
$component
==
$name
||
(
$component
==
$alias
&&
(
$name
==
$this
->
name
||
in_array
(
$name
,
$this
->
parents
))))
{
}
elseif
(
$component
==
$name
||
(
$component
==
$alias
))
{
// && ($name == $this->name || in_array($name,$this->parents))
if
(
!
isset
(
$local
))
$local
=
$this
->
identifier
;
...
...
@@ -666,9 +664,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
}
}
$this
->
relations
[
$alias
]
=
$relation
;
return
$this
->
relations
[
$alias
];
}
// load all relations
$this
->
getRelations
();
...
...
tests/RelationTestCase.php
View file @
599dc759
<?php
class
RelationTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
}
public
function
setUp
()
{
$this
->
ownsMany
(
'OwnsOneToManyWithAlias as AliasO2M'
,
'AliasO2M.component_id'
);
$this
->
hasMany
(
'HasManyToManyWithAlias as AliasM2M'
,
'JoinTable.c1_id'
);
}
}
class
HasOneToOne
extends
Doctrine_Record
{
}
class
HasOneToOneWithAlias
extends
Doctrine_Record
{
}
class
JoinTable
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'c1_id'
,
'integer'
);
$this
->
hasColumn
(
'c2_id'
,
'integer'
);
}
}
class
HasManyWithAlias
extends
Doctrine_Record
{
}
class
OwnsOneToManyWithAlias
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'component_id'
,
'integer'
);
}
public
function
setUp
()
{
}
}
class
HasManyToManyWithAlias
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
}
public
function
setUp
()
{
$this
->
hasMany
(
'RelationTest as AliasM2M'
,
'JoinTable.c2_id'
);
}
}
class
Doctrine_Relation_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
();
$this
->
tables
=
array
();
}
public
function
testOneToManyOwnsRelationWithAliases
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
,
false
);
$component
=
new
RelationTest
();
try
{
$rel
=
$component
->
getTable
()
->
getRelation
(
'AliasO2M'
);
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
$this
->
assertTrue
(
$rel
instanceof
Doctrine_Relation_ForeignKey
);
}
public
function
testManyToManyHasRelationWithAliases
()
{
$component
=
new
RelationTest
();
try
{
$rel
=
$component
->
getTable
()
->
getRelation
(
'AliasM2M'
);
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
$this
->
assertTrue
(
$rel
instanceof
Doctrine_Relation_Association
);
}
public
function
testManyToManyRelation
()
{
$user
=
new
User
();
...
...
@@ -31,5 +95,7 @@ class Doctrine_Relation_TestCase extends Doctrine_UnitTestCase {
$user
=
new
User
();
$this
->
assertTrue
(
$user
->
getTable
()
->
getRelation
(
'Phonenumber'
)
instanceof
Doctrine_Relation_ForeignKey
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
,
true
);
}
}
tests/run.php
View file @
599dc759
...
...
@@ -56,14 +56,14 @@ print "<pre>";
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
$test
->
addTestCase
(
new
Doctrine_Relation_TestCase
());
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_ValidatorTestCase
());
$test
->
addTestCase
(
new
Doctrine_Query_MultiJoin_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Relation_TestCase
());
$test
->
addTestCase
(
new
Doctrine_EventListenerTestCase
());
$test
->
addTestCase
(
new
Doctrine_Connection_Transaction_TestCase
());
...
...
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