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
f6af2616
Commit
f6af2616
authored
Apr 18, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
b71ac561
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
Mysql.php
lib/Doctrine/Export/Mysql.php
+21
-19
No files found.
lib/Doctrine/Export/Mysql.php
View file @
f6af2616
...
...
@@ -285,9 +285,9 @@ class Doctrine_Export_Mysql extends Doctrine_Export
*/
public
function
alterTableSql
(
$name
,
array
$changes
,
$check
)
{
if
(
!
$name
)
if
(
!
$name
)
{
throw
new
Doctrine_Export_Exception
(
'no valid table name specified'
);
}
foreach
(
$changes
as
$changeName
=>
$change
)
{
switch
(
$changeName
)
{
case
'add'
:
...
...
@@ -297,7 +297,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
case
'name'
:
break
;
default
:
throw
new
Doctrine_Export_Exception
(
'change type "'
.
$changeName
.
'" not yet supported'
);
throw
new
Doctrine_Export_Exception
(
'change type "'
.
$changeName
.
'" not yet supported'
);
}
}
...
...
@@ -307,33 +307,33 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$query
=
''
;
if
(
!
empty
(
$changes
[
'name'
]))
{
$change_name
=
$this
->
conn
->
quoteIdentifier
(
$changes
[
'name'
]
,
true
);
$change_name
=
$this
->
conn
->
quoteIdentifier
(
$changes
[
'name'
]);
$query
.=
'RENAME TO '
.
$change_name
;
}
if
(
!
empty
(
$changes
[
'add'
])
&&
is_array
(
$changes
[
'add'
]))
{
foreach
(
$changes
[
'add'
]
as
$field
_n
ame
=>
$field
)
{
foreach
(
$changes
[
'add'
]
as
$field
N
ame
=>
$field
)
{
if
(
$query
)
{
$query
.=
', '
;
}
$query
.=
'ADD '
.
$this
->
getDeclaration
(
$field
[
'type'
],
$field
_n
ame
,
$field
);
$query
.=
'ADD '
.
$this
->
getDeclaration
(
$field
[
'type'
],
$field
N
ame
,
$field
);
}
}
if
(
!
empty
(
$changes
[
'remove'
])
&&
is_array
(
$changes
[
'remove'
]))
{
foreach
(
$changes
[
'remove'
]
as
$field
_n
ame
=>
$field
)
{
foreach
(
$changes
[
'remove'
]
as
$field
N
ame
=>
$field
)
{
if
(
$query
)
{
$query
.=
', '
;
$query
.=
', '
;
}
$field
_name
=
$this
->
conn
->
quoteIdentifier
(
$field_name
,
tru
e
);
$query
.=
'DROP '
.
$field_n
ame
;
$field
Name
=
$this
->
conn
->
quoteIdentifier
(
$fieldNam
e
);
$query
.=
'DROP '
.
$fieldN
ame
;
}
}
$rename
=
array
();
if
(
!
empty
(
$changes
[
'rename'
])
&&
is_array
(
$changes
[
'rename'
]))
{
foreach
(
$changes
[
'rename'
]
as
$field
_n
ame
=>
$field
)
{
$rename
[
$field
[
'name'
]]
=
$field
_n
ame
;
foreach
(
$changes
[
'rename'
]
as
$field
N
ame
=>
$field
)
{
$rename
[
$field
[
'name'
]]
=
$field
N
ame
;
}
}
...
...
@@ -349,18 +349,20 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$oldFieldName
=
$fieldName
;
}
$oldFieldName
=
$this
->
conn
->
quoteIdentifier
(
$oldFieldName
,
true
);
$query
.=
"CHANGE
$oldFieldName
"
.
$this
->
getDeclaration
(
$field
[
'definition'
][
'type'
],
$fieldName
,
$field
[
'definition'
]);
$query
.=
'CHANGE '
.
$oldFieldName
.
' '
.
$this
->
getDeclaration
(
$field
[
'definition'
][
'type'
],
$fieldName
,
$field
[
'definition'
]);
}
}
if
(
!
empty
(
$rename
)
&&
is_array
(
$rename
))
{
foreach
(
$rename
as
$rename
_name
=>
$renamed_f
ield
)
{
foreach
(
$rename
as
$rename
Name
=>
$renamedF
ield
)
{
if
(
$query
)
{
$query
.=
', '
;
}
$field
=
$changes
[
'rename'
][
$renamed_field
];
$renamed_field
=
$this
->
conn
->
quoteIdentifier
(
$renamed_field
,
true
);
$query
.=
'CHANGE '
.
$renamed_field
.
' '
.
$this
->
getDeclaration
(
$field
[
'definition'
][
'type'
],
$field
[
'name'
],
$field
[
'definition'
]);
$field
=
$changes
[
'rename'
][
$renamedField
];
$renamedField
=
$this
->
conn
->
quoteIdentifier
(
$renamedField
,
true
);
$query
.=
'CHANGE '
.
$renamedField
.
' '
.
$this
->
getDeclaration
(
$field
[
'definition'
][
'type'
],
$field
[
'name'
],
$field
[
'definition'
]);
}
}
...
...
@@ -452,7 +454,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$table
=
$table
;
$name
=
$this
->
conn
->
getIndexName
(
$name
);
$type
=
''
;
if
(
isset
(
$definition
[
'type'
]))
{
if
(
isset
(
$definition
[
'type'
]))
{
switch
(
strtolower
(
$definition
[
'type'
]))
{
case
'fulltext'
:
case
'unique'
:
...
...
@@ -463,7 +465,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
}
}
$query
=
'CREATE '
.
$type
.
'INDEX '
.
$name
.
' ON '
.
$table
;
$query
.=
' ('
.
$this
->
getIndexFieldDeclarationList
()
.
')'
;
$query
.=
' ('
.
$this
->
getIndexFieldDeclarationList
()
.
')'
;
return
$query
;
}
...
...
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