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
ff733916
Commit
ff733916
authored
May 20, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
7c2dc1a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
1 deletion
+74
-1
Parser.php
lib/Doctrine/Relation/Parser.php
+74
-1
No files found.
lib/Doctrine/Relation/Parser.php
View file @
ff733916
...
...
@@ -109,13 +109,86 @@ class Doctrine_Relation_Parser
$this
->
_pending
[
$alias
]
=
array_merge
(
$options
,
array
(
'class'
=>
$name
,
'alias'
=>
$alias
));
}
public
function
getRelation
(
$name
,
$recursive
=
true
)
{
if
(
isset
(
$this
->
_relations
[
$name
]))
{
return
$this
->
_relations
[
$name
];
}
if
(
isset
(
$this
->
_pending
[
$name
]))
{
$def
=
$this
->
_pending
[
$name
];
}
}
public
function
completeDefinition
(
$def
)
{
$def
[
'table'
]
=
$this
->
_table
->
getConnection
()
->
getTable
(
$def
[
'class'
]);
if
(
isset
(
$def
[
'local'
]))
{
if
(
!
isset
(
$def
[
'foreign'
]))
{
// local key is set, but foreign key is not
// try to guess the foreign key
if
(
$def
[
'local'
]
===
$this
->
_table
->
getIdentifier
())
{
$column
=
strtolower
(
$this
->
_table
->
getComponentName
())
.
'_'
.
$this
->
_table
->
getIdentifier
();
if
(
!
$def
[
'table'
]
->
hasColumn
(
$column
))
{
// auto-add column
}
$def
[
'foreign'
]
=
$column
;
}
else
{
// the foreign field is likely to be the
// identifier of the foreign class
$def
[
'foreign'
]
=
$def
[
'table'
]
->
getIdentifier
();
}
}
}
else
{
if
(
isset
(
$def
[
'foreign'
]))
{
// local key not set, but foreign key is set
// try to guess the local key
if
(
$def
[
'foreign'
]
===
$this
->
_table
->
getIdentifier
())
{
$column
=
strtolower
(
$def
[
'table'
]
->
getComponentName
())
.
'_'
.
$def
[
'table'
]
->
getIdentifier
();
$def
[
'local'
]
=
$column
;
}
else
{
$def
[
'local'
]
=
$this
->
_table
->
getIdentifier
();
}
}
else
{
// neither local or foreign key is being set
// try to guess both keys
$column
=
strtolower
(
$this
->
_table
->
getComponentName
())
.
'_'
.
$this
->
_table
->
getIdentifier
();
if
(
$def
[
'table'
]
->
hasColumn
(
$column
))
{
$def
[
'foreign'
]
=
$column
;
$def
[
'local'
]
=
$this
->
_table
->
getIdentifier
();
}
else
{
$column
=
strtolower
(
$def
[
'table'
]
->
getComponentName
())
.
'_'
.
$def
[
'table'
]
->
getIdentifier
();
if
(
$this
->
_table
->
hasColumn
(
$column
))
{
$def
[
'foreign'
]
=
$def
[
'table'
]
->
getIdentifier
();
$def
[
'local'
]
=
$column
;
}
}
}
}
return
$def
;
}
/**
* getRelation
*
* @param string $name component name of which a foreign key object is bound
* @return Doctrine_Relation
*/
public
function
getRelation
(
$name
,
$recursive
=
true
)
public
function
getRelation
2
(
$name
,
$recursive
=
true
)
{
if
(
isset
(
$this
->
relations
[
$name
]))
{
return
$this
->
relations
[
$name
];
...
...
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