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
e7bb7593
Commit
e7bb7593
authored
Jan 21, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #85 from kimhemsoe/drizzle
[WIP] Drizzle Support
parents
f45c5ade
d95ed401
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
708 additions
and
0 deletions
+708
-0
Connection.php
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php
+36
-0
Driver.php
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
+93
-0
DriverManager.php
lib/Doctrine/DBAL/DriverManager.php
+1
-0
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+10
-0
DrizzlePlatform.php
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
+409
-0
DrizzleKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php
+44
-0
Connection.php
lib/Doctrine/DBAL/Portability/Connection.php
+3
-0
DrizzleSchemaManager.php
lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
+96
-0
DrizzleSchemaManagerTest.php
...Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
+12
-0
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+4
-0
No files found.
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php
0 → 100644
View file @
e7bb7593
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Driver\DrizzlePDOMySql
;
class
Connection
extends
\Doctrine\DBAL\Driver\PDOConnection
{
public
function
quote
(
$value
,
$type
=
\PDO
::
PARAM_STR
)
{
if
(
\PDO
::
PARAM_BOOL
===
$type
)
{
if
(
$value
)
{
return
'true'
;
}
else
{
return
'false'
;
}
}
return
parent
::
quote
(
$value
,
$type
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
0 → 100644
View file @
e7bb7593
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Driver\DrizzlePDOMySql
;
/**
* Drizzle driver using PDO MySql.
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class
Driver
implements
\Doctrine\DBAL\Driver
{
/**
* Attempts to establish a connection with the underlying driver.
*
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
* @return Doctrine\DBAL\Driver\Connection
*/
public
function
connect
(
array
$params
,
$username
=
null
,
$password
=
null
,
array
$driverOptions
=
array
())
{
$conn
=
new
Connection
(
$this
->
_constructPdoDsn
(
$params
),
$username
,
$password
,
$driverOptions
);
return
$conn
;
}
/**
* Constructs the Drizzle MySql PDO DSN.
*
* @return string The DSN.
*/
private
function
_constructPdoDsn
(
array
$params
)
{
$dsn
=
'mysql:'
;
if
(
isset
(
$params
[
'host'
])
&&
$params
[
'host'
]
!=
''
)
{
$dsn
.=
'host='
.
$params
[
'host'
]
.
';'
;
}
if
(
isset
(
$params
[
'port'
]))
{
$dsn
.=
'port='
.
$params
[
'port'
]
.
';'
;
}
if
(
isset
(
$params
[
'dbname'
]))
{
$dsn
.=
'dbname='
.
$params
[
'dbname'
]
.
';'
;
}
if
(
isset
(
$params
[
'unix_socket'
]))
{
$dsn
.=
'unix_socket='
.
$params
[
'unix_socket'
]
.
';'
;
}
return
$dsn
;
}
public
function
getDatabasePlatform
()
{
return
new
\Doctrine\DBAL\Platforms\DrizzlePlatform
();
}
public
function
getSchemaManager
(
\Doctrine\DBAL\Connection
$conn
)
{
return
new
\Doctrine\DBAL\Schema\DrizzleSchemaManager
(
$conn
);
}
public
function
getName
()
{
return
'drizzle_pdo_mysql'
;
}
public
function
getDatabase
(
\Doctrine\DBAL\Connection
$conn
)
{
$params
=
$conn
->
getParams
();
return
$params
[
'dbname'
];
}
}
\ No newline at end of file
lib/Doctrine/DBAL/DriverManager.php
View file @
e7bb7593
...
...
@@ -45,6 +45,7 @@ final class DriverManager
'pdo_ibm'
=>
'Doctrine\DBAL\Driver\PDOIbm\Driver'
,
'pdo_sqlsrv'
=>
'Doctrine\DBAL\Driver\PDOSqlsrv\Driver'
,
'mysqli'
=>
'Doctrine\DBAL\Driver\Mysqli\Driver'
,
'drizzle_pdo_mysql'
=>
'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver'
,
);
/** Private constructor. This class cannot be instantiated. */
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
e7bb7593
...
...
@@ -2408,6 +2408,16 @@ abstract class AbstractPlatform
return
""
;
}
/**
* Does this platform views ?
*
* @return boolean
*/
public
function
supportsViews
()
{
return
true
;
}
/**
* Gets the format string, as accepted by the date() function, that describes
* the format of a stored datetime value of this platform.
...
...
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
0 → 100644
View file @
e7bb7593
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\DBAL\DBALException
,
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Schema\Index
,
Doctrine\DBAL\Schema\Table
;
/**
* Drizzle platform
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class
DrizzlePlatform
extends
AbstractPlatform
{
/**
* Get the platform name for this instance.
*
* @return string
*/
public
function
getName
()
{
return
'drizzle'
;
}
/**
* Gets the character used for identifier quoting.
*
* @return string
* @override
*/
public
function
getIdentifierQuoteCharacter
()
{
return
'`'
;
}
public
function
getConcatExpression
()
{
$args
=
func_get_args
();
return
'CONCAT('
.
join
(
', '
,
(
array
)
$args
)
.
')'
;
}
public
function
getDateDiffExpression
(
$date1
,
$date2
)
{
return
'DATEDIFF('
.
$date1
.
', '
.
$date2
.
')'
;
}
public
function
getDateAddDaysExpression
(
$date
,
$days
)
{
return
'DATE_ADD('
.
$date
.
', INTERVAL '
.
$days
.
' DAY)'
;
}
public
function
getDateSubDaysExpression
(
$date
,
$days
)
{
return
'DATE_SUB('
.
$date
.
', INTERVAL '
.
$days
.
' DAY)'
;
}
public
function
getDateAddMonthExpression
(
$date
,
$months
)
{
return
'DATE_ADD('
.
$date
.
', INTERVAL '
.
$months
.
' MONTH)'
;
}
public
function
getDateSubMonthExpression
(
$date
,
$months
)
{
return
'DATE_SUB('
.
$date
.
', INTERVAL '
.
$months
.
' MONTH)'
;
}
/**
* @override
*/
public
function
getBooleanTypeDeclarationSQL
(
array
$field
)
{
return
'BOOLEAN'
;
}
public
function
getIntegerTypeDeclarationSQL
(
array
$field
)
{
return
'INT'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
protected
function
_getCommonIntegerTypeDeclarationSQL
(
array
$columnDef
)
{
$autoinc
=
''
;
if
(
!
empty
(
$columnDef
[
'autoincrement'
]))
{
$autoinc
=
' AUTO_INCREMENT'
;
}
return
$autoinc
;
}
public
function
getBigIntTypeDeclarationSQL
(
array
$field
)
{
return
'BIGINT'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
public
function
getSmallIntTypeDeclarationSQL
(
array
$field
)
{
return
'INT'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
return
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
;
}
protected
function
initializeDoctrineTypeMappings
()
{
$this
->
doctrineTypeMapping
=
array
(
'boolean'
=>
'boolean'
,
'varchar'
=>
'string'
,
'integer'
=>
'integer'
,
'blob'
=>
'text'
,
'decimal'
=>
'decimal'
,
'datetime'
=>
'datetime'
,
'date'
=>
'date'
,
'time'
=>
'time'
,
'text'
=>
'text'
,
'timestamp'
=>
'datetime'
,
'double'
=>
'float'
,
'bigint'
=>
'bigint'
,
);
}
public
function
getClobTypeDeclarationSQL
(
array
$field
)
{
return
'TEXT'
;
}
/**
* Gets the SQL Snippet used to declare a BLOB column type.
*/
public
function
getBlobTypeDeclarationSQL
(
array
$field
)
{
return
'BLOB'
;
}
public
function
getCreateDatabaseSQL
(
$name
)
{
return
'CREATE DATABASE '
.
$name
;
}
public
function
getDropDatabaseSQL
(
$name
)
{
return
'DROP DATABASE '
.
$name
;
}
public
function
getListDatabasesSQL
()
{
return
"SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE CATALOG_NAME='LOCAL'"
;
}
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\DrizzleKeywords'
;
}
public
function
getListTablesSQL
()
{
return
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE' AND TABLE_SCHEMA=DATABASE()"
;
}
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
if
(
$database
)
{
$database
=
"'"
.
$database
.
"'"
;
}
else
{
$database
=
'DATABASE()'
;
}
return
"SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT, IS_NULLABLE, IS_AUTO_INCREMENT, CHARACTER_MAXIMUM_LENGTH, COLUMN_DEFAULT,"
.
" NUMERIC_PRECISION, NUMERIC_SCALE"
.
" FROM DATA_DICTIONARY.COLUMNS"
.
" WHERE TABLE_SCHEMA="
.
$database
.
" AND TABLE_NAME = '"
.
$table
.
"'"
;
}
public
function
getListTableForeignKeysSQL
(
$table
,
$database
=
null
)
{
if
(
$database
)
{
$database
=
"'"
.
$database
.
"'"
;
}
else
{
$database
=
'DATABASE()'
;
}
return
"SELECT CONSTRAINT_NAME, CONSTRAINT_COLUMNS, REFERENCED_TABLE_NAME, REFERENCED_TABLE_COLUMNS, UPDATE_RULE, DELETE_RULE"
.
" FROM DATA_DICTIONARY.FOREIGN_KEYS"
.
" WHERE CONSTRAINT_SCHEMA="
.
$database
.
" AND CONSTRAINT_TABLE='"
.
$table
.
"'"
;
}
public
function
getListTableIndexesSQL
(
$table
,
$database
=
null
)
{
if
(
$database
)
{
$database
=
"'"
.
$database
.
"'"
;
}
else
{
$database
=
'DATABASE()'
;
}
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
()
{
return
true
;
}
public
function
supportsIdentityColumns
()
{
return
true
;
}
public
function
supportsInlineColumnComments
()
{
return
true
;
}
public
function
supportsViews
()
{
return
false
;
}
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'
;
}
public
function
getDateTimeTypeDeclarationSQL
(
array
$fieldDeclaration
)
{
if
(
isset
(
$fieldDeclaration
[
'version'
])
&&
$fieldDeclaration
[
'version'
]
==
true
)
{
return
'TIMESTAMP'
;
}
else
{
return
'DATETIME'
;
}
}
public
function
getTimeTypeDeclarationSQL
(
array
$fieldDeclaration
)
{
return
'TIME'
;
}
public
function
getDateTypeDeclarationSQL
(
array
$fieldDeclaration
)
{
return
'DATE'
;
}
public
function
getAlterTableSQL
(
TableDiff
$diff
)
{
$columnSql
=
array
();
$queryParts
=
array
();
if
(
$diff
->
newName
!==
false
)
{
$queryParts
[]
=
'RENAME TO '
.
$diff
->
newName
;
}
foreach
(
$diff
->
addedColumns
AS
$fieldName
=>
$column
)
{
if
(
$this
->
onSchemaAlterTableAddColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'ADD '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$columnArray
);
}
foreach
(
$diff
->
removedColumns
AS
$column
)
{
if
(
$this
->
onSchemaAlterTableRemoveColumn
(
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$queryParts
[]
=
'DROP '
.
$column
->
getQuotedName
(
$this
);
}
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
if
(
$this
->
onSchemaAlterTableChangeColumn
(
$columnDiff
,
$diff
,
$columnSql
))
{
continue
;
}
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
$column
=
$columnDiff
->
column
;
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'CHANGE '
.
(
$columnDiff
->
oldColumnName
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$columnArray
);
}
foreach
(
$diff
->
renamedColumns
AS
$oldColumnName
=>
$column
)
{
if
(
$this
->
onSchemaAlterTableRenameColumn
(
$oldColumnName
,
$column
,
$diff
,
$columnSql
))
{
continue
;
}
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'CHANGE '
.
$oldColumnName
.
' '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$columnArray
);
}
$sql
=
array
();
$tableSql
=
array
();
if
(
!
$this
->
onSchemaAlterTable
(
$diff
,
$tableSql
))
{
if
(
count
(
$queryParts
)
>
0
)
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' '
.
implode
(
", "
,
$queryParts
);
}
$sql
=
array_merge
(
$this
->
getPreAlterTableIndexForeignKeySQL
(
$diff
),
$sql
,
$this
->
getPostAlterTableIndexForeignKeySQL
(
$diff
)
);
}
return
array_merge
(
$sql
,
$tableSql
,
$columnSql
);
}
public
function
getDropTemporaryTableSQL
(
$table
)
{
if
(
$table
instanceof
\Doctrine\DBAL\Schema\Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
}
else
if
(
!
is_string
(
$table
))
{
throw
new
\InvalidArgumentException
(
'getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'
);
}
return
'DROP TEMPORARY TABLE '
.
$table
;
}
public
function
convertBooleans
(
$item
)
{
if
(
is_array
(
$item
))
{
foreach
(
$item
as
$key
=>
$value
)
{
if
(
is_bool
(
$value
)
||
is_numeric
(
$item
))
{
$item
[
$key
]
=
(
$value
)
?
'true'
:
'false'
;
}
}
}
else
{
if
(
is_bool
(
$item
)
||
is_numeric
(
$item
))
{
$item
=
(
$item
)
?
'true'
:
'false'
;
}
}
return
$item
;
return
$item
;
}
public
function
getLocateExpression
(
$str
,
$substr
,
$startPos
=
false
)
{
if
(
$startPos
==
false
)
{
return
'LOCATE('
.
$substr
.
', '
.
$str
.
')'
;
}
else
{
return
'LOCATE('
.
$substr
.
', '
.
$str
.
', '
.
$startPos
.
')'
;
}
}
public
function
getGuidExpression
()
{
return
'UUID()'
;
}
public
function
getRegexpExpression
()
{
return
'RLIKE'
;
}
}
lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php
0 → 100644
View file @
e7bb7593
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* MySQL Keywordlist
*
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author David Coallier <davidc@php.net>
*/
class
DrizzleKeywords
extends
KeywordList
{
public
function
getName
()
{
return
'drizzle'
;
}
protected
function
getKeywords
()
{
return
array
(
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Portability/Connection.php
View file @
e7bb7593
...
...
@@ -37,6 +37,7 @@ class Connection extends \Doctrine\DBAL\Connection
const
PORTABILITY_POSTGRESQL
=
13
;
const
PORTABILITY_SQLITE
=
13
;
const
PORTABILITY_OTHERVENDORS
=
12
;
const
PORTABILITY_DRIZZLE
=
13
;
/**
* @var int
...
...
@@ -60,6 +61,8 @@ class Connection extends \Doctrine\DBAL\Connection
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_POSTGRESQL
;
}
else
if
(
$this
->
_platform
->
getName
()
===
"sqlite"
)
{
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLITE
;
}
else
if
(
$this
->
_platform
->
getName
()
===
"drizzle"
)
{
$params
[
'portability'
]
=
self
::
PORTABILITY_DRIZZLE
;
}
else
{
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_OTHERVENDORS
;
}
...
...
lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
0 → 100644
View file @
e7bb7593
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Schema
;
/**
* Schema manager for the Drizzle RDBMS.
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class
DrizzleSchemaManager
extends
AbstractSchemaManager
{
protected
function
_getPortableTableColumnDefinition
(
$tableColumn
)
{
$tableName
=
$tableColumn
[
'COLUMN_NAME'
];
$dbType
=
strtolower
(
$tableColumn
[
'DATA_TYPE'
]);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
extractDoctrineTypeFromComment
(
$tableColumn
[
'COLUMN_COMMENT'
],
$type
);
$tableColumn
[
'COLUMN_COMMENT'
]
=
$this
->
removeDoctrineTypeFromComment
(
$tableColumn
[
'COLUMN_COMMENT'
],
$type
);
$options
=
array
(
'notnull'
=>
!
(
bool
)
$tableColumn
[
'IS_NULLABLE'
],
'length'
=>
(
int
)
$tableColumn
[
'CHARACTER_MAXIMUM_LENGTH'
],
'default'
=>
empty
(
$tableColumn
[
'COLUMN_DEFAULT'
])
?
null
:
$tableColumn
[
'COLUMN_DEFAULT'
],
'autoincrement'
=>
(
bool
)
$tableColumn
[
'IS_AUTO_INCREMENT'
],
'scale'
=>
(
int
)
$tableColumn
[
'NUMERIC_SCALE'
],
'precision'
=>
(
int
)
$tableColumn
[
'NUMERIC_PRECISION'
],
'comment'
=>
(
isset
(
$tableColumn
[
'COLUMN_COMMENT'
])
?
$tableColumn
[
'COLUMN_COMMENT'
]
:
null
),
);
return
new
Column
(
$tableName
,
\Doctrine\DBAL\Types\Type
::
getType
(
$type
),
$options
);
}
protected
function
_getPortableDatabaseDefinition
(
$database
)
{
return
$database
[
'SCHEMA_NAME'
];
}
protected
function
_getPortableTableDefinition
(
$table
)
{
return
$table
[
'TABLE_NAME'
];
}
public
function
_getPortableTableForeignKeyDefinition
(
$tableForeignKey
)
{
$columns
=
array
();
foreach
(
explode
(
','
,
$tableForeignKey
[
'CONSTRAINT_COLUMNS'
])
as
$value
)
{
$columns
[]
=
trim
(
$value
,
' `'
);
}
$ref_columns
=
array
();
foreach
(
explode
(
','
,
$tableForeignKey
[
'REFERENCED_TABLE_COLUMNS'
])
as
$value
)
{
$ref_columns
[]
=
trim
(
$value
,
' `'
);
}
return
new
ForeignKeyConstraint
(
$columns
,
$tableForeignKey
[
'REFERENCED_TABLE_NAME'
],
$ref_columns
,
$tableForeignKey
[
'CONSTRAINT_NAME'
],
array
(
'onUpdate'
=>
$tableForeignKey
[
'UPDATE_RULE'
],
'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
);
}
}
tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
0 → 100644
View file @
e7bb7593
<?php
namespace
Doctrine\Tests\DBAL\Functional\Schema
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\Schema
;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
DrizzleSchemaManagerTest
extends
SchemaManagerFunctionalTestCase
{
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
e7bb7593
...
...
@@ -438,6 +438,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
public
function
testCreateAndListViews
()
{
if
(
!
$this
->
_sm
->
getDatabasePlatform
()
->
supportsViews
())
{
$this
->
markTestSkipped
(
'Views is not supported by this platform.'
);
}
$this
->
createTestTable
(
'view_test_table'
);
$name
=
"doctrine_test_view"
;
...
...
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