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
c12f764c
Commit
c12f764c
authored
Jun 18, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for index auto-adding
parent
1ad4afaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
+25
-3
Mysql.php
lib/Doctrine/Export/Mysql.php
+25
-3
No files found.
lib/Doctrine/Export/Mysql.php
View file @
c12f764c
...
...
@@ -97,12 +97,33 @@ class Doctrine_Export_Mysql extends Doctrine_Export
}
$queryFields
=
$this
->
getFieldDeclarationList
(
$fields
);
// build indexes for all foreign key fields (needed in MySQL!!)
if
(
isset
(
$options
[
'foreignKeys'
]))
{
foreach
(
$options
[
'foreignKeys'
]
as
$fk
)
{
$local
=
$fk
[
'local'
];
$found
=
false
;
if
(
isset
(
$options
[
'indexes'
]))
{
foreach
(
$options
[
'indexes'
]
as
$definition
)
{
if
(
isset
(
$definition
[
'fields'
][
$local
])
&&
count
(
$definition
[
'fields'
])
===
1
)
{
$found
=
true
;
}
}
}
if
(
!
$found
)
{
$options
[
'indexes'
]
=
array
(
$local
=>
array
(
'fields'
=>
array
(
$local
=>
array
())));
}
}
}
// add all indexes
if
(
isset
(
$options
[
'indexes'
])
&&
!
empty
(
$options
[
'indexes'
]))
{
foreach
(
$options
[
'indexes'
]
as
$index
=>
$definition
)
{
$queryFields
.=
', '
.
$this
->
getIndexDeclaration
(
$index
,
$definition
);
}
}
// attach all primary keys
if
(
isset
(
$options
[
'primary'
])
&&
!
empty
(
$options
[
'primary'
]))
{
$queryFields
.=
', PRIMARY KEY('
.
implode
(
', '
,
array_values
(
$options
[
'primary'
]))
.
')'
;
}
...
...
@@ -124,7 +145,8 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$type
=
false
;
if
(
!
empty
(
$options
[
'type'
]))
{
// get the type of the table
if
(
!
empty
(
$options
[
'type'
]))
{
$type
=
$options
[
'type'
];
}
else
{
$type
=
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_DEFAULT_TABLE_TYPE
);
...
...
@@ -144,7 +166,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
foreach
((
array
)
$options
[
'foreignKeys'
]
as
$k
=>
$definition
)
{
if
(
is_array
(
$definition
))
{
if
(
!
isset
(
$definition
[
'table'
]))
{
$definition
[
'table'
]
=
$name
;
$definition
[
'table'
]
=
$name
;
}
$sql
[]
=
$this
->
createForeignKeySql
(
$definition
[
'table'
],
$definition
);
}
...
...
@@ -515,7 +537,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$definition
[
'fields'
]
=
array
(
$definition
[
'fields'
]);
}
$query
=
$type
.
'INDEX '
.
$
name
;
$query
=
$type
.
'INDEX '
.
$
this
->
conn
->
formatter
->
getIndexName
(
$name
)
;
$query
.=
' ('
.
$this
->
getIndexFieldDeclarationList
(
$definition
[
'fields'
])
.
')'
;
...
...
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