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
Expand all
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
...
@@ -45,6 +45,7 @@ final class DriverManager
'pdo_ibm'
=>
'Doctrine\DBAL\Driver\PDOIbm\Driver'
,
'pdo_ibm'
=>
'Doctrine\DBAL\Driver\PDOIbm\Driver'
,
'pdo_sqlsrv'
=>
'Doctrine\DBAL\Driver\PDOSqlsrv\Driver'
,
'pdo_sqlsrv'
=>
'Doctrine\DBAL\Driver\PDOSqlsrv\Driver'
,
'mysqli'
=>
'Doctrine\DBAL\Driver\Mysqli\Driver'
,
'mysqli'
=>
'Doctrine\DBAL\Driver\Mysqli\Driver'
,
'drizzle_pdo_mysql'
=>
'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver'
,
);
);
/** Private constructor. This class cannot be instantiated. */
/** Private constructor. This class cannot be instantiated. */
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
e7bb7593
...
@@ -2408,6 +2408,16 @@ abstract class AbstractPlatform
...
@@ -2408,6 +2408,16 @@ abstract class AbstractPlatform
return
""
;
return
""
;
}
}
/**
* Does this platform views ?
*
* @return boolean
*/
public
function
supportsViews
()
{
return
true
;
}
/**
/**
* Gets the format string, as accepted by the date() function, that describes
* Gets the format string, as accepted by the date() function, that describes
* the format of a stored datetime value of this platform.
* the format of a stored datetime value of this platform.
...
...
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
0 → 100644
View file @
e7bb7593
This diff is collapsed.
Click to expand it.
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
...
@@ -37,6 +37,7 @@ class Connection extends \Doctrine\DBAL\Connection
const
PORTABILITY_POSTGRESQL
=
13
;
const
PORTABILITY_POSTGRESQL
=
13
;
const
PORTABILITY_SQLITE
=
13
;
const
PORTABILITY_SQLITE
=
13
;
const
PORTABILITY_OTHERVENDORS
=
12
;
const
PORTABILITY_OTHERVENDORS
=
12
;
const
PORTABILITY_DRIZZLE
=
13
;
/**
/**
* @var int
* @var int
...
@@ -60,6 +61,8 @@ class Connection extends \Doctrine\DBAL\Connection
...
@@ -60,6 +61,8 @@ class Connection extends \Doctrine\DBAL\Connection
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_POSTGRESQL
;
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_POSTGRESQL
;
}
else
if
(
$this
->
_platform
->
getName
()
===
"sqlite"
)
{
}
else
if
(
$this
->
_platform
->
getName
()
===
"sqlite"
)
{
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLITE
;
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLITE
;
}
else
if
(
$this
->
_platform
->
getName
()
===
"drizzle"
)
{
$params
[
'portability'
]
=
self
::
PORTABILITY_DRIZZLE
;
}
else
{
}
else
{
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_OTHERVENDORS
;
$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
...
@@ -438,6 +438,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
public
function
testCreateAndListViews
()
public
function
testCreateAndListViews
()
{
{
if
(
!
$this
->
_sm
->
getDatabasePlatform
()
->
supportsViews
())
{
$this
->
markTestSkipped
(
'Views is not supported by this platform.'
);
}
$this
->
createTestTable
(
'view_test_table'
);
$this
->
createTestTable
(
'view_test_table'
);
$name
=
"doctrine_test_view"
;
$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