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
2cc12a17
Unverified
Commit
2cc12a17
authored
Apr 07, 2018
by
Michael Moravec
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bpo/2.7/#3088' into 2.7
Backporting #3088 into 2.7
parents
9beff5ef
51cc243b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
2 deletions
+72
-2
PDOStatement.php
lib/Doctrine/DBAL/Driver/PDOStatement.php
+18
-2
PDOStatementTest.php
tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php
+54
-0
No files found.
lib/Doctrine/DBAL/Driver/PDOStatement.php
View file @
2cc12a17
...
@@ -22,6 +22,9 @@ namespace Doctrine\DBAL\Driver;
...
@@ -22,6 +22,9 @@ namespace Doctrine\DBAL\Driver;
use
Doctrine\DBAL\FetchMode
;
use
Doctrine\DBAL\FetchMode
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\ParameterType
;
use
PDO
;
use
PDO
;
use
const
E_USER_DEPRECATED
;
use
function
sprintf
;
use
function
trigger_error
;
/**
/**
* The PDO implementation of the Statement interface.
* The PDO implementation of the Statement interface.
...
@@ -213,7 +216,13 @@ class PDOStatement extends \PDOStatement implements Statement
...
@@ -213,7 +216,13 @@ class PDOStatement extends \PDOStatement implements Statement
private
function
convertParamType
(
int
$type
)
:
int
private
function
convertParamType
(
int
$type
)
:
int
{
{
if
(
!
isset
(
self
::
PARAM_TYPE_MAP
[
$type
]))
{
if
(
!
isset
(
self
::
PARAM_TYPE_MAP
[
$type
]))
{
throw
new
\InvalidArgumentException
(
'Invalid parameter type: '
.
$type
);
// TODO: next major: throw an exception
@
trigger_error
(
sprintf
(
'Using a PDO parameter type (%d given) is deprecated and will cause an error in Doctrine 3.0'
,
$type
),
E_USER_DEPRECATED
);
return
$type
;
}
}
return
self
::
PARAM_TYPE_MAP
[
$type
];
return
self
::
PARAM_TYPE_MAP
[
$type
];
...
@@ -231,7 +240,14 @@ class PDOStatement extends \PDOStatement implements Statement
...
@@ -231,7 +240,14 @@ class PDOStatement extends \PDOStatement implements Statement
}
}
if
(
!
isset
(
self
::
FETCH_MODE_MAP
[
$fetchMode
]))
{
if
(
!
isset
(
self
::
FETCH_MODE_MAP
[
$fetchMode
]))
{
throw
new
\InvalidArgumentException
(
'Invalid fetch mode: '
.
$fetchMode
);
// TODO: next major: throw an exception
@
trigger_error
(
sprintf
(
'Using a PDO fetch mode or their combination (%d given)'
.
' is deprecated and will cause an error in Doctrine 3.0'
,
$fetchMode
),
E_USER_DEPRECATED
);
return
$fetchMode
;
}
}
return
self
::
FETCH_MODE_MAP
[
$fetchMode
];
return
self
::
FETCH_MODE_MAP
[
$fetchMode
];
...
...
tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php
0 → 100644
View file @
2cc12a17
<?php
namespace
Doctrine\Tests\DBAL\Functional
;
use
Doctrine\DBAL\Driver\PDOConnection
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\Tests\DbalFunctionalTestCase
;
use
PDO
;
use
function
extension_loaded
;
class
PDOStatementTest
extends
DbalFunctionalTestCase
{
protected
function
setUp
()
{
if
(
!
extension_loaded
(
'pdo'
))
{
$this
->
markTestSkipped
(
'PDO is not installed'
);
}
parent
::
setUp
();
if
(
!
$this
->
_conn
->
getWrappedConnection
()
instanceof
PDOConnection
)
{
$this
->
markTestSkipped
(
'PDO-only test'
);
}
$table
=
new
Table
(
'stmt_test'
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addColumn
(
'name'
,
'text'
);
$this
->
_conn
->
getSchemaManager
()
->
dropAndCreateTable
(
$table
);
}
/**
* @group legacy
* @expectedDeprecation Using a PDO fetch mode or their combination (%d given) is deprecated and will cause an error in Doctrine 3.0
*/
public
function
testPDOSpecificModeIsAccepted
()
{
$this
->
_conn
->
insert
(
'stmt_test'
,
[
'id'
=>
1
,
'name'
=>
'Alice'
,
]);
$this
->
_conn
->
insert
(
'stmt_test'
,
[
'id'
=>
2
,
'name'
=>
'Bob'
,
]);
$data
=
$this
->
_conn
->
query
(
'SELECT id, name FROM stmt_test ORDER BY id'
)
->
fetchAll
(
PDO
::
FETCH_KEY_PAIR
);
self
::
assertSame
([
1
=>
'Alice'
,
2
=>
'Bob'
,
],
$data
);
}
}
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