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
7f1666ef
Commit
7f1666ef
authored
Aug 10, 2007
by
njero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes to make hasOne relations with 'foreign' and 'local' work as expected
parent
5aaa598f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
Record.php
lib/Doctrine/Record.php
+1
-1
LocalKey.php
lib/Doctrine/Relation/LocalKey.php
+22
-2
No files found.
lib/Doctrine/Record.php
View file @
7f1666ef
...
...
@@ -883,7 +883,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
throw
new
Doctrine_Record_Exception
(
"Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references."
);
}
if
(
$rel
instanceof
Doctrine_Relation_LocalKey
)
{
$this
->
set
(
$rel
->
getLocal
(),
$value
,
false
);
$this
->
set
(
$rel
->
getLocal
(),
$value
->
rawGet
(
$rel
->
getForeign
())
,
false
);
}
else
{
$value
->
set
(
$rel
->
getForeign
(),
$this
,
false
);
}
...
...
lib/Doctrine/Relation/LocalKey.php
View file @
7f1666ef
...
...
@@ -48,7 +48,13 @@ class Doctrine_Relation_LocalKey extends Doctrine_Relation
if
(
empty
(
$id
)
||
!
$this
->
definition
[
'table'
]
->
getAttribute
(
Doctrine
::
ATTR_LOAD_REFERENCES
))
{
$related
=
$this
->
getTable
()
->
create
();
}
else
{
$related
=
$this
->
getTable
()
->
find
(
$id
);
$dql
=
'FROM '
.
$this
->
getTable
()
->
getComponentName
()
.
' WHERE '
.
$this
->
getCondition
();
$related
=
$this
->
getTable
()
->
getConnection
()
->
query
(
$dql
,
array
(
$id
))
->
getFirst
();
if
(
!
$related
)
{
$related
=
$this
->
getTable
()
->
create
();
...
...
@@ -59,4 +65,18 @@ class Doctrine_Relation_LocalKey extends Doctrine_Relation
return
$related
;
}
/**
* getCondition
*
* @param string $alias
*/
public
function
getCondition
(
$alias
=
null
)
{
if
(
!
$alias
)
{
$alias
=
$this
->
getTable
()
->
getComponentName
();
}
return
$alias
.
'.'
.
$this
->
definition
[
'foreign'
]
.
' = ?'
;
}
}
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