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
88ef777f
Commit
88ef777f
authored
Sep 28, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Doctrine_Record, added Doctrine_Relation::isOneToOne
parent
25956bea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
97 deletions
+91
-97
Hydrate.php
lib/Doctrine/Hydrate.php
+7
-12
Record.php
lib/Doctrine/Record.php
+74
-85
Relation.php
lib/Doctrine/Relation.php
+10
-0
No files found.
lib/Doctrine/Hydrate.php
View file @
88ef777f
...
...
@@ -349,19 +349,14 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$last
=
$prev
[
$pointer
]
->
getLast
();
switch
(
$fk
->
getType
())
:
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
ONE_AGGREGATE
:
break
;
default
:
if
(
!
$fk
->
isOneToOne
())
{
if
(
$last
instanceof
Doctrine_Record
)
{
if
(
!
$last
->
hasReference
(
$alias
))
{
$prev
[
$name
]
=
$this
->
getCollection
(
$name
);
$last
->
initReference
(
$prev
[
$name
],
$fk
);
}
}
endswitch
;
}
continue
;
}
...
...
lib/Doctrine/Record.php
View file @
88ef777f
...
...
@@ -453,13 +453,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
cleanData
();
$exists
=
true
;
if
(
$this
->
state
==
Doctrine_Record
::
STATE_TDIRTY
||
$this
->
state
==
Doctrine_Record
::
STATE_TCLEAN
)
$exists
=
false
;
$this
->
prepareIdentifiers
(
$exists
);
$this
->
prepareIdentifiers
(
$this
->
exists
());
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onWakeUp
(
$this
);
}
...
...
@@ -1158,16 +1152,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*
* @param Doctrine_Collection $coll
* @param Doctrine_Relation $connector
* @return
void
* @return
boolean
*/
public
function
initReference
(
Doctrine_Collection
$coll
,
Doctrine_Relation
$connector
)
{
$alias
=
$connector
->
getAlias
();
if
(
isset
(
$this
->
references
[
$alias
]))
return
false
;
if
(
!
$connector
->
isOneToOne
())
{
if
(
!
(
$connector
instanceof
Doctrine_Association
))
$coll
->
setReference
(
$this
,
$connector
);
$this
->
references
[
$alias
]
=
$coll
;
$this
->
originals
[
$alias
]
=
clone
$coll
;
return
true
;
}
return
false
;
}
/**
* addReference
...
...
@@ -1216,13 +1218,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$graph
=
$table
->
getQueryObject
();
$type
=
$fk
->
getType
();
switch
(
$this
->
getState
())
:
case
Doctrine_Record
::
STATE_TDIRTY
:
case
Doctrine_Record
::
STATE_TCLEAN
:
if
(
$type
==
Doctrine_Relation
::
ONE_COMPOSITE
||
$type
==
Doctrine_Relation
::
ONE_AGGREGATE
)
{
if
(
!
$this
->
exists
())
{
if
(
$fk
->
isOneToOne
())
{
// ONE-TO-ONE
$this
->
references
[
$name
]
=
$table
->
create
();
...
...
@@ -1239,15 +1236,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
$this
->
originals
[
$name
]
=
new
Doctrine_Collection
(
$table
);
}
break
;
case
Doctrine_Record
::
STATE_DIRTY
:
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_PROXY
:
switch
(
$fk
->
getType
())
:
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
ONE_AGGREGATE
:
}
else
{
if
(
$fk
->
isOneToOne
())
{
// ONE-TO-ONE
$id
=
$this
->
get
(
$local
);
...
...
@@ -1281,8 +1271,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
references
[
$name
]
->
set
(
$fk
->
getForeign
(),
$this
);
}
}
break
;
default
:
}
else
{
$query
=
$fk
->
getRelationDql
(
1
);
// ONE-TO-MANY
...
...
@@ -1298,9 +1288,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
$this
->
references
[
$name
]
=
$coll
;
$this
->
originals
[
$name
]
=
clone
$coll
;
endswitch
;
break
;
endswitch
;
}
}
}
/**
* filterRelated
...
...
lib/Doctrine/Relation.php
View file @
88ef777f
...
...
@@ -131,6 +131,16 @@ class Doctrine_Relation {
final
public
function
getForeign
()
{
return
$this
->
foreign
;
}
/**
* isOneToOne
* returns whether or not this relation is a one-to-one relation
*
* @return boolean
*/
final
public
function
isOneToOne
()
{
return
(
$this
->
type
==
Doctrine_Relation
::
ONE_AGGREGATE
||
$this
->
type
==
Doctrine_Relation
::
ONE_COMPOSITE
);
}
/**
* getRelationDql
*
...
...
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