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
5773cf08
Commit
5773cf08
authored
Dec 24, 2011
by
Kim Hemsø Rasmussen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial drizzle support. create, drop, list databases and list tables.
parent
b066e54f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
368 additions
and
0 deletions
+368
-0
Driver.php
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
+95
-0
DriverManager.php
lib/Doctrine/DBAL/DriverManager.php
+1
-0
DrizzlePlatform.php
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
+165
-0
DrizzleKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php
+44
-0
DrizzleSchemaManager.php
lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php
+51
-0
DrizzleSchemaManagerTest.php
...Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
+12
-0
No files found.
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
0 → 100644
View file @
5773cf08
<?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
;
use
Doctrine\DBAL\Connection
;
/**
* 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
\Doctrine\DBAL\Driver\PDOConnection
(
$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 @
5773cf08
...
...
@@ -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/DrizzlePlatform.php
0 → 100644
View file @
5773cf08
<?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
'`'
;
}
/**
* @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'
,
);
}
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, COLUMN_TYPE, COLUMN_COMMENT, IS_NULLABLE"
.
" FROM DATA_DICTIONARY.COLUMNS"
.
" WHERE TABLE_SCHEMA="
.
$database
.
" AND TABLE_NAME = '"
.
$table
.
"'"
;
}
public
function
getListTableForeignKeysSQL
(
$table
,
$database
=
null
)
{
return
"SELECT * FROM DATA_DICTIONARY.FOREIGN_KEYS"
;
}
public
function
getListTableIndexesSQL
(
$table
,
$database
=
null
)
{
return
"SELECT * FROM DATA_DICTIONARY.INDEXES WHERE FALSE"
;
}
}
lib/Doctrine/DBAL/Platforms/Keywords/DrizzleKeywords.php
0 → 100644
View file @
5773cf08
<?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/Schema/DrizzleSchemaManager.php
0 → 100644
View file @
5773cf08
<?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.
*
*/
class
DrizzleSchemaManager
extends
AbstractSchemaManager
{
protected
function
_getPortableTableColumnDefinition
(
$tableColumn
)
{
$tableName
=
$tableColumn
[
'COLUMN_NAME'
];
$dbType
=
strtolower
(
$tableColumn
[
'COLUMN_TYPE'
]);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
extractDoctrineTypeFromComment
(
$tableColumn
[
'COLUMN_COMMENT'
],
$type
);
$options
=
array
();
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'
];
}
}
tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
0 → 100644
View file @
5773cf08
<?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
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