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
03bc9350
Commit
03bc9350
authored
Dec 08, 2009
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-156 - Allow to pass custom platforms
parent
845c8555
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
Connection.php
lib/Doctrine/DBAL/Connection.php
+9
-2
DBALException.php
lib/Doctrine/DBAL/DBALException.php
+5
-0
DriverManagerTest.php
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+12
-0
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
03bc9350
...
...
@@ -22,7 +22,8 @@
namespace
Doctrine\DBAL
;
use
Doctrine\Common\EventManager
,
Doctrine\Common\DoctrineException
;
Doctrine\Common\DoctrineException
,
Doctrine\DBAL\DBALException
;
/**
* A wrapper around a Doctrine\DBAL\Driver\Connection that adds features like
...
...
@@ -178,7 +179,13 @@ class Connection
$this
->
_config
=
$config
;
$this
->
_eventManager
=
$eventManager
;
$this
->
_platform
=
$driver
->
getDatabasePlatform
();
if
(
!
isset
(
$params
[
'platform'
]))
{
$this
->
_platform
=
$driver
->
getDatabasePlatform
();
}
else
if
(
$params
[
'platform'
]
instanceof
\Doctrine\DBAL\Platforms\AbstractPlatform
)
{
$this
->
_platform
=
$params
[
'platform'
];
}
else
{
throw
DBALException
::
invalidPlatformSpecified
();
}
$this
->
_transactionIsolationLevel
=
$this
->
_platform
->
getDefaultTransactionIsolationLevel
();
}
...
...
lib/Doctrine/DBAL/DBALException.php
View file @
03bc9350
...
...
@@ -8,4 +8,9 @@ class DBALException extends \Exception
{
return
new
self
(
"Operation '
$method
' is not supported."
);
}
public
static
function
invalidPlatformSpecified
()
{
return
new
self
(
"Invalid 'platform' option specified, need to give an instance of \Doctrine\DBAL\Platforms\AbstractPlatform."
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
View file @
03bc9350
...
...
@@ -49,4 +49,16 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
{
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
array
(
'driver'
=>
'invalid_driver'
));
}
public
function
testCustomPlatform
()
{
$mockPlatform
=
new
\Doctrine\Tests\DBAL\Mocks\MockPlatform
();
$options
=
array
(
'pdo'
=>
new
\PDO
(
'sqlite::memory:'
),
'platform'
=>
$mockPlatform
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
$this
->
assertSame
(
$mockPlatform
,
$conn
->
getDatabasePlatform
());
}
}
\ 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