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
dbfd1070
Unverified
Commit
dbfd1070
authored
Jul 09, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw DBALException instead of driver exception from wrapper classes
parent
d415d040
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
Connection.php
src/Connection.php
+17
-7
Statement.php
src/Statement.php
+18
-5
No files found.
src/Connection.php
View file @
dbfd1070
...
...
@@ -215,7 +215,7 @@ class Connection
{
$platform
=
$this
->
getDatabasePlatform
();
$query
=
$platform
->
getDummySelectSQL
(
$platform
->
getCurrentDatabaseExpression
());
$database
=
$this
->
query
(
$query
)
->
fetchOne
(
);
$database
=
$this
->
fetchOne
(
$query
);
assert
(
is_string
(
$database
)
||
$database
===
null
);
...
...
@@ -344,7 +344,7 @@ class Connection
*
* @return string|null
*
* @throws Exception
* @throws
DBAL
Exception
*/
private
function
getDatabasePlatformVersion
()
{
...
...
@@ -408,7 +408,11 @@ class Connection
// Automatic platform version detection.
if
(
$connection
instanceof
ServerInfoAwareConnection
)
{
return
$connection
->
getServerVersion
();
try
{
return
$connection
->
getServerVersion
();
}
catch
(
DriverException
$e
)
{
throw
$this
->
convertException
(
$e
);
}
}
// Unable to detect platform version.
...
...
@@ -1131,10 +1135,16 @@ class Connection
* @param string|null $seqName Name of the sequence object from which the ID should be returned.
*
* @return string A string representation of the last inserted ID.
*
* @throws DBALException
*/
public
function
lastInsertId
(
$seqName
=
null
)
{
return
$this
->
getWrappedConnection
()
->
lastInsertId
(
$seqName
);
try
{
return
$this
->
getWrappedConnection
()
->
lastInsertId
(
$seqName
);
}
catch
(
DriverException
$e
)
{
throw
$this
->
convertException
(
$e
);
}
}
/**
...
...
@@ -1386,7 +1396,7 @@ class Connection
throw
ConnectionException
::
savepointsNotSupported
();
}
$this
->
getWrappedConnection
()
->
exec
(
$this
->
platform
->
createSavePoint
(
$savepoint
));
$this
->
executeUpdate
(
$this
->
platform
->
createSavePoint
(
$savepoint
));
}
/**
...
...
@@ -1408,7 +1418,7 @@ class Connection
return
;
}
$this
->
getWrappedConnection
()
->
exec
(
$this
->
platform
->
releaseSavePoint
(
$savepoint
));
$this
->
executeUpdate
(
$this
->
platform
->
releaseSavePoint
(
$savepoint
));
}
/**
...
...
@@ -1426,7 +1436,7 @@ class Connection
throw
ConnectionException
::
savepointsNotSupported
();
}
$this
->
getWrappedConnection
()
->
exec
(
$this
->
platform
->
rollbackSavePoint
(
$savepoint
));
$this
->
executeUpdate
(
$this
->
platform
->
rollbackSavePoint
(
$savepoint
));
}
/**
...
...
src/Statement.php
View file @
dbfd1070
...
...
@@ -95,27 +95,34 @@ class Statement
* @param mixed $type Either a PDO binding type or a DBAL mapping type name or instance.
*
* @return bool TRUE on success, FALSE on failure.
*
* @throws DBALException
*/
public
function
bindValue
(
$name
,
$value
,
$type
=
ParameterType
::
STRING
)
{
$this
->
params
[
$name
]
=
$value
;
$this
->
types
[
$name
]
=
$type
;
$bindingType
=
ParameterType
::
STRING
;
if
(
$type
!==
null
)
{
if
(
is_string
(
$type
))
{
$type
=
Type
::
getType
(
$type
);
}
$bindingType
=
$type
;
if
(
$type
instanceof
Type
)
{
$value
=
$type
->
convertToDatabaseValue
(
$value
,
$this
->
platform
);
$bindingType
=
$type
->
getBindingType
();
}
else
{
$bindingType
=
$type
;
}
}
try
{
return
$this
->
stmt
->
bindValue
(
$name
,
$value
,
$bindingType
);
}
catch
(
Exception
$e
)
{
throw
$this
->
conn
->
convertException
(
$e
);
}
return
$this
->
stmt
->
bindValue
(
$name
,
$value
);
}
/**
...
...
@@ -130,13 +137,19 @@ class Statement
* so that PHP allocates enough memory to hold the returned value.
*
* @return bool TRUE on success, FALSE on failure.
*
* @throws DBALException
*/
public
function
bindParam
(
$name
,
&
$var
,
$type
=
ParameterType
::
STRING
,
$length
=
null
)
{
$this
->
params
[
$name
]
=
$var
;
$this
->
types
[
$name
]
=
$type
;
return
$this
->
stmt
->
bindParam
(
$name
,
$var
,
$type
,
$length
);
try
{
return
$this
->
stmt
->
bindParam
(
$name
,
$var
,
$type
,
$length
);
}
catch
(
Exception
$e
)
{
throw
$this
->
conn
->
convertException
(
$e
);
}
}
/**
...
...
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