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
94089fd9
Commit
94089fd9
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 unknown table for mysql and sqlite
parent
6b2b0a49
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
0 deletions
+15
-0
DBALException.php
lib/Doctrine/DBAL/DBALException.php
+1
-0
Driver.php
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
+2
-0
Driver.php
lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
+4
-0
ExceptionTest.php
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
+8
-0
No files found.
lib/Doctrine/DBAL/DBALException.php
View file @
94089fd9
...
...
@@ -22,6 +22,7 @@ namespace Doctrine\DBAL;
class
DBALException
extends
\Exception
{
const
ERROR_DUPLICATE_KEY
=
1
;
const
ERROR_UNKNOWN_TABLE
=
2
;
/**
* @param string $method
...
...
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
View file @
94089fd9
...
...
@@ -118,6 +118,8 @@ class Driver implements \Doctrine\DBAL\Driver
switch
(
$exception
->
getCode
())
{
case
23000
:
return
DBALException
::
ERROR_DUPLICATE_KEY
;
case
'42S02'
:
return
DBALException
::
ERROR_UNKNOWN_TABLE
;
}
return
0
;
...
...
lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
View file @
94089fd9
...
...
@@ -122,6 +122,10 @@ class Driver implements \Doctrine\DBAL\Driver
switch
(
$exception
->
getCode
())
{
case
23000
:
return
DBALException
::
ERROR_DUPLICATE_KEY
;
case
'HY000'
:
if
(
strpos
(
$exception
->
getMessage
(),
'no such table:'
)
!==
false
)
{
return
DBALException
::
ERROR_UNKNOWN_TABLE
;
}
}
return
0
;
...
...
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
View file @
94089fd9
...
...
@@ -23,5 +23,13 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
setExpectedException
(
'\Doctrine\DBAL\DBALException'
,
null
,
DBALException
::
ERROR_DUPLICATE_KEY
);
$this
->
_conn
->
insert
(
"duplicatekey_table"
,
array
(
'id'
=>
1
));
}
public
function
testUnknownTableException
()
{
$sql
=
"SELECT * FROM unknown_table"
;
$this
->
setExpectedException
(
'\Doctrine\DBAL\DBALException'
,
null
,
DBALException
::
ERROR_UNKNOWN_TABLE
);
$this
->
_conn
->
executeQuery
(
$sql
);
}
}
\ 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