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
49d2dd9b
Commit
49d2dd9b
authored
Feb 13, 2010
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-329 - Allow Reverse Engineering with multiple column foreign keys
parent
5a96217d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
16 deletions
+7
-16
DatabaseDriver.php
lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
+7
-16
No files found.
lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
View file @
49d2dd9b
...
@@ -124,30 +124,21 @@ class DatabaseDriver implements Driver
...
@@ -124,30 +124,21 @@ class DatabaseDriver implements Driver
}
}
foreach
(
$foreignKeys
as
$foreignKey
)
{
foreach
(
$foreignKeys
as
$foreignKey
)
{
if
(
count
(
$foreignKey
->
getColumns
())
!=
1
)
{
throw
new
MappingException
(
"Cannot generate mapping for table '"
.
$tableName
.
"' with foreign keys with multiple local columns."
);
}
$cols
=
$foreignKey
->
getColumns
();
$cols
=
$foreignKey
->
getColumns
();
$localColumn
=
current
(
$cols
);
$localColumn
=
current
(
$cols
);
$fkCols
=
$foreignKey
->
getForeignColumns
();
$fkCols
=
$foreignKey
->
getForeignColumns
();
if
(
count
(
$fkCols
)
!=
1
)
{
throw
new
MappingException
(
"Cannot generate mapping for table '"
.
$tableName
.
"' with foreign keys with multiple foreign columns."
);
}
$foreignColumn
=
current
(
$fkCols
);
$associationMapping
=
array
();
$associationMapping
=
array
();
$associationMapping
[
'fieldName'
]
=
Inflector
::
camelize
(
str_ireplace
(
'_id'
,
''
,
$localColumn
));
$associationMapping
[
'fieldName'
]
=
Inflector
::
camelize
(
str_ireplace
(
'_id'
,
''
,
$localColumn
));
$associationMapping
[
'columnName'
]
=
$localColumn
;
$associationMapping
[
'targetEntity'
]
=
Inflector
::
classify
(
$foreignKey
->
getForeignTableName
());
$associationMapping
[
'targetEntity'
]
=
Inflector
::
classify
(
$foreignKey
->
getForeignTableName
());
for
(
$i
=
0
;
$i
<
count
(
$cols
);
$i
++
)
{
$associationMapping
[
'joinColumns'
][]
=
array
(
$associationMapping
[
'joinColumns'
][]
=
array
(
'name'
=>
$localColumn
,
'name'
=>
$cols
[
$i
]
,
'referencedColumnName'
=>
$foreignColumn
'referencedColumnName'
=>
$fkCols
[
$i
],
);
);
}
$metadata
->
mapManyToOne
(
$associationMapping
);
$metadata
->
mapManyToOne
(
$associationMapping
);
}
}
...
...
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