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
6b2b0a49
Commit
6b2b0a49
authored
Aug 27, 2013
by
dazz
Committed by
Benjamin Eberlei
Nov 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-407] Implement error detection on duplicate key for mysql and sqlite
parent
e85e7130
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletion
+13
-1
DBALException.php
lib/Doctrine/DBAL/DBALException.php
+1
-1
Driver.php
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
+6
-0
Driver.php
lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
+6
-0
No files found.
lib/Doctrine/DBAL/DBALException.php
View file @
6b2b0a49
...
@@ -91,7 +91,7 @@ class DBALException extends \Exception
...
@@ -91,7 +91,7 @@ class DBALException extends \Exception
}
}
$msg
.=
":
\n\n
"
.
$driverEx
->
getMessage
();
$msg
.=
":
\n\n
"
.
$driverEx
->
getMessage
();
return
new
self
(
$msg
,
0
,
$driverEx
);
return
new
self
(
$msg
,
$driver
->
convertExceptionCode
(
$driverEx
)
,
$driverEx
);
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
View file @
6b2b0a49
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
namespace
Doctrine\DBAL\Driver\PDOMySql
;
namespace
Doctrine\DBAL\Driver\PDOMySql
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\DBALException
;
/**
/**
* PDO MySql driver.
* PDO MySql driver.
...
@@ -114,6 +115,11 @@ class Driver implements \Doctrine\DBAL\Driver
...
@@ -114,6 +115,11 @@ class Driver implements \Doctrine\DBAL\Driver
*/
*/
public
function
convertExceptionCode
(
\Exception
$exception
)
public
function
convertExceptionCode
(
\Exception
$exception
)
{
{
switch
(
$exception
->
getCode
())
{
case
23000
:
return
DBALException
::
ERROR_DUPLICATE_KEY
;
}
return
0
;
return
0
;
}
}
}
}
lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
View file @
6b2b0a49
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
*/
*/
namespace
Doctrine\DBAL\Driver\PDOSqlite
;
namespace
Doctrine\DBAL\Driver\PDOSqlite
;
use
Doctrine\DBAL\DBALException
;
/**
/**
* The PDO Sqlite driver.
* The PDO Sqlite driver.
...
@@ -118,6 +119,11 @@ class Driver implements \Doctrine\DBAL\Driver
...
@@ -118,6 +119,11 @@ class Driver implements \Doctrine\DBAL\Driver
*/
*/
public
function
convertExceptionCode
(
\Exception
$exception
)
public
function
convertExceptionCode
(
\Exception
$exception
)
{
{
switch
(
$exception
->
getCode
())
{
case
23000
:
return
DBALException
::
ERROR_DUPLICATE_KEY
;
}
return
0
;
return
0
;
}
}
}
}
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