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
05b48352
Commit
05b48352
authored
Dec 25, 2011
by
Kim Hemsø Rasmussen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Index support
parent
0541b30a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
5 deletions
+58
-5
DrizzlePlatform.php
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
+45
-1
DrizzleSchemaManager.php
lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
+13
-4
No files found.
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
View file @
05b48352
...
...
@@ -167,7 +167,16 @@ class DrizzlePlatform extends AbstractPlatform
public
function
getListTableIndexesSQL
(
$table
,
$database
=
null
)
{
return
"SELECT * FROM DATA_DICTIONARY.INDEXES WHERE FALSE"
;
if
(
$database
)
{
$database
=
"'"
.
$database
.
"'"
;
}
else
{
$database
=
'DATABASE()'
;
}
// INDEX_NAME AS 'key_name', COLUMN_NAME AS 'column_name', IS_USED_IN_PRIMARY AS 'primary', IS_UNIQUE=0 AS 'non_unique'
return
"SELECT INDEX_NAME AS 'key_name', COLUMN_NAME AS 'column_name', IS_USED_IN_PRIMARY AS 'primary', IS_UNIQUE=0 AS 'non_unique'"
.
" FROM DATA_DICTIONARY.INDEX_PARTS"
.
" WHERE TABLE_SCHEMA="
.
$database
.
" AND TABLE_NAME='"
.
$table
.
"'"
;
}
public
function
prefersIdentityColumns
()
...
...
@@ -184,4 +193,39 @@ class DrizzlePlatform extends AbstractPlatform
{
return
true
;
}
public
function
getDropIndexSQL
(
$index
,
$table
=
null
)
{
if
(
$index
instanceof
Index
)
{
$indexName
=
$index
->
getQuotedName
(
$this
);
}
else
if
(
is_string
(
$index
))
{
$indexName
=
$index
;
}
else
{
throw
new
\InvalidArgumentException
(
'DrizzlePlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.'
);
}
if
(
$table
instanceof
Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
}
else
if
(
!
is_string
(
$table
))
{
throw
new
\InvalidArgumentException
(
'DrizzlePlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'
);
}
if
(
$index
instanceof
Index
&&
$index
->
isPrimary
())
{
// drizzle 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 '
.
$indexName
.
' ON '
.
$table
;
}
/**
* @param Index $index
* @param Table $table
*/
protected
function
getDropPrimaryKeySQL
(
$table
)
{
return
'ALTER TABLE '
.
$table
.
' DROP PRIMARY KEY'
;
}
}
lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
View file @
05b48352
...
...
@@ -22,6 +22,7 @@ namespace Doctrine\DBAL\Schema;
/**
* Schema manager for the Drizzle RDBMS.
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class
DrizzleSchemaManager
extends
AbstractSchemaManager
{
...
...
@@ -54,14 +55,12 @@ class DrizzleSchemaManager extends AbstractSchemaManager
public
function
_getPortableTableForeignKeyDefinition
(
$tableForeignKey
)
{
$columns
=
array
();
foreach
(
explode
(
','
,
$tableForeignKey
[
'CONSTRAINT_COLUMNS'
])
as
$value
)
{
foreach
(
explode
(
','
,
$tableForeignKey
[
'CONSTRAINT_COLUMNS'
])
as
$value
)
{
$columns
[]
=
trim
(
$value
,
'`'
);
}
$ref_columns
=
array
();
foreach
(
explode
(
','
,
$tableForeignKey
[
'REFERENCED_TABLE_COLUMNS'
])
as
$value
)
{
foreach
(
explode
(
','
,
$tableForeignKey
[
'REFERENCED_TABLE_COLUMNS'
])
as
$value
)
{
$ref_columns
[]
=
trim
(
$value
,
'`'
);
}
...
...
@@ -75,7 +74,17 @@ class DrizzleSchemaManager extends AbstractSchemaManager
'onDelete'
=>
$tableForeignKey
[
'DELETE_RULE'
],
)
);
}
protected
function
_getPortableTableIndexesList
(
$tableIndexes
,
$tableName
=
null
)
{
$indexes
=
array
();
foreach
(
$tableIndexes
as
$k
)
{
$k
[
'primary'
]
=
(
boolean
)
$k
[
'primary'
];
$indexes
[]
=
$k
;
}
return
parent
::
_getPortableTableIndexesList
(
$indexes
,
$tableName
);
}
}
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