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
a880811a
Commit
a880811a
authored
Jun 26, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DBAL-126 - Special case for dropping MySQL Primary keys
parent
4c383bd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
7 deletions
+26
-7
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+26
-7
No files found.
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
a880811a
...
@@ -20,7 +20,9 @@
...
@@ -20,7 +20,9 @@
namespace
Doctrine\DBAL\Platforms
;
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\DBAL\DBALException
,
use
Doctrine\DBAL\DBALException
,
Doctrine\DBAL\Schema\TableDiff
;
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Schema\Index
,
Doctrine\DBAL\Schema\Table
;
/**
/**
* The MySqlPlatform provides the behavior, features and SQL dialect of the
* The MySqlPlatform provides the behavior, features and SQL dialect of the
...
@@ -576,20 +578,37 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -576,20 +578,37 @@ class MySqlPlatform extends AbstractPlatform
* @override
* @override
*/
*/
public
function
getDropIndexSQL
(
$index
,
$table
=
null
)
public
function
getDropIndexSQL
(
$index
,
$table
=
null
)
{
{
if
(
$index
instanceof
\Doctrine\DBAL\Schema\Index
)
{
if
(
$index
instanceof
Index
)
{
$index
=
$index
->
getQuotedName
(
$this
);
$indexName
=
$index
->
getQuotedName
(
$this
);
}
else
if
(
!
is_string
(
$index
))
{
}
else
if
(
is_string
(
$index
))
{
$indexName
=
$index
;
}
else
{
throw
new
\InvalidArgumentException
(
'MysqlPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'
);
throw
new
\InvalidArgumentException
(
'MysqlPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'
);
}
}
if
(
$table
instanceof
\Doctrine\DBAL\Schema\
Table
)
{
if
(
$table
instanceof
Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
$table
=
$table
->
getQuotedName
(
$this
);
}
else
if
(
!
is_string
(
$table
))
{
}
else
if
(
!
is_string
(
$table
))
{
throw
new
\InvalidArgumentException
(
'MysqlPlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'
);
throw
new
\InvalidArgumentException
(
'MysqlPlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'
);
}
}
if
(
$index
instanceof
Index
&&
$index
->
isPrimary
())
{
// mysql primary keys are always named "PRIMARY",
// so we cannot use them in statements because of them being keyword.
return
$this
->
getDropPrimaryKeySQL
(
$table
);
}
return
'DROP INDEX '
.
$index
.
' ON '
.
$table
;
return
'DROP INDEX '
.
$indexName
.
' ON '
.
$table
;
}
/**
* @param Index $index
* @param Table $table
*/
protected
function
getDropPrimaryKeySQL
(
$table
)
{
return
'ALTER TABLE '
.
$table
.
' DROP PRIMARY KEY'
;
}
}
/**
/**
...
...
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