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
8fd22324
Commit
8fd22324
authored
Nov 19, 2013
by
Kim Hemsø Rasmussen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement ExceptionConverterDriver for drizzle_pdo_mysql
parent
2deaa6a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
Driver.php
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
+38
-1
ExceptionTest.php
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
+4
-0
No files found.
lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php
View file @
8fd22324
...
@@ -19,12 +19,15 @@
...
@@ -19,12 +19,15 @@
namespace
Doctrine\DBAL\Driver\DrizzlePDOMySql
;
namespace
Doctrine\DBAL\Driver\DrizzlePDOMySql
;
use
Doctrine\DBAL\Driver\ExceptionConverterDriver
;
use
Doctrine\DBAL\DBALException
;
/**
/**
* Drizzle driver using PDO MySql.
* Drizzle driver using PDO MySql.
*
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
*/
class
Driver
implements
\Doctrine\DBAL\Driver
class
Driver
implements
\Doctrine\DBAL\Driver
,
ExceptionConverterDriver
{
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
@@ -105,6 +108,40 @@ class Driver implements \Doctrine\DBAL\Driver
...
@@ -105,6 +108,40 @@ class Driver implements \Doctrine\DBAL\Driver
*/
*/
public
function
convertExceptionCode
(
\Exception
$exception
)
public
function
convertExceptionCode
(
\Exception
$exception
)
{
{
if
(
$exception
->
getCode
()
===
"42000"
)
{
return
DBALException
::
ERROR_SYNTAX
;
}
if
(
$exception
->
getCode
()
===
"42S02"
)
{
return
DBALException
::
ERROR_UNKNOWN_TABLE
;
}
if
(
$exception
->
getCode
()
===
"42S01"
)
{
return
DBALException
::
ERROR_TABLE_ALREADY_EXISTS
;
}
if
(
$exception
->
getCode
()
===
"42S22"
)
{
return
DBALException
::
ERROR_BAD_FIELD_NAME
;
}
if
(
$exception
->
getCode
()
===
"23000"
)
{
if
(
strpos
(
$exception
->
getMessage
(),
'Duplicate entry'
)
!==
false
)
{
return
DBALException
::
ERROR_DUPLICATE_KEY
;
}
if
(
strpos
(
$exception
->
getMessage
(),
'Cannot delete or update a parent row: a foreign key constraint fails'
)
!==
false
)
{
return
DBALException
::
ERROR_FOREIGN_KEY_CONSTRAINT
;
}
if
(
strpos
(
$exception
->
getMessage
(),
' cannot be null'
))
{
return
DBALException
::
ERROR_NOT_NULL
;
}
if
(
strpos
(
$exception
->
getMessage
(),
'in field list is ambiguous'
)
!==
false
)
{
return
DBALException
::
ERROR_NON_UNIQUE_FIELD_NAME
;
}
}
return
0
;
return
0
;
}
}
}
}
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
View file @
8fd22324
...
@@ -217,6 +217,10 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -217,6 +217,10 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
markTestSkipped
(
"Only skipped if platform is not sqlite"
);
$this
->
markTestSkipped
(
"Only skipped if platform is not sqlite"
);
}
}
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
getName
()
==
'drizzle'
)
{
$this
->
markTestSkipped
(
"Drizzle does not always support authentication"
);
}
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
getName
()
==
'postgresql'
&&
isset
(
$params
[
'password'
]))
{
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
getName
()
==
'postgresql'
&&
isset
(
$params
[
'password'
]))
{
$this
->
markTestSkipped
(
"Does not work on Travis"
);
$this
->
markTestSkipped
(
"Does not work on Travis"
);
}
}
...
...
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