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
c0533c1d
Commit
c0533c1d
authored
May 05, 2012
by
Nicolas Grekas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use "fetchMode" instead of "fetchStyle"
parent
e0d1cd21
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
124 additions
and
124 deletions
+124
-124
ArrayStatement.php
lib/Doctrine/DBAL/Cache/ArrayStatement.php
+11
-11
ResultCacheStatement.php
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+13
-13
Connection.php
lib/Doctrine/DBAL/Connection.php
+8
-8
DB2Statement.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+9
-9
MysqliStatement.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+10
-10
OCI8Connection.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
+1
-1
OCI8Statement.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+18
-18
PDOStatement.php
lib/Doctrine/DBAL/Driver/PDOStatement.php
+4
-4
ResultStatement.php
lib/Doctrine/DBAL/Driver/ResultStatement.php
+6
-6
SQLSrvStatement.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+10
-10
Statement.php
lib/Doctrine/DBAL/Portability/Statement.php
+13
-13
Statement.php
lib/Doctrine/DBAL/Statement.php
+9
-9
ResultCacheTest.php
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
+10
-10
HydratorMockStatement.php
tests/Doctrine/Tests/Mocks/HydratorMockStatement.php
+2
-2
No files found.
lib/Doctrine/DBAL/Cache/ArrayStatement.php
View file @
c0533c1d
...
@@ -27,7 +27,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
...
@@ -27,7 +27,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
private
$data
;
private
$data
;
private
$columnCount
=
0
;
private
$columnCount
=
0
;
private
$num
=
0
;
private
$num
=
0
;
private
$defaultFetch
Styl
e
=
PDO
::
FETCH_BOTH
;
private
$defaultFetch
Mod
e
=
PDO
::
FETCH_BOTH
;
public
function
__construct
(
array
$data
)
public
function
__construct
(
array
$data
)
{
{
...
@@ -47,13 +47,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
...
@@ -47,13 +47,13 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return
$this
->
columnCount
;
return
$this
->
columnCount
;
}
}
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
)
{
{
if
(
$arg2
!==
null
||
$arg3
!==
null
)
{
if
(
$arg2
!==
null
||
$arg3
!==
null
)
{
throw
new
\InvalidArgumentException
(
"Caching layer does not support 2nd/3rd argument to setFetchMode()"
);
throw
new
\InvalidArgumentException
(
"Caching layer does not support 2nd/3rd argument to setFetchMode()"
);
}
}
$this
->
defaultFetch
Style
=
$fetchStyl
e
;
$this
->
defaultFetch
Mode
=
$fetchMod
e
;
}
}
public
function
getIterator
()
public
function
getIterator
()
...
@@ -62,18 +62,18 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
...
@@ -62,18 +62,18 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return
new
\ArrayIterator
(
$data
);
return
new
\ArrayIterator
(
$data
);
}
}
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
if
(
isset
(
$this
->
data
[
$this
->
num
]))
{
if
(
isset
(
$this
->
data
[
$this
->
num
]))
{
$row
=
$this
->
data
[
$this
->
num
++
];
$row
=
$this
->
data
[
$this
->
num
++
];
$fetch
Style
=
$fetchStyle
?:
$this
->
defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
defaultFetchMod
e
;
if
(
$fetch
Styl
e
===
PDO
::
FETCH_ASSOC
)
{
if
(
$fetch
Mod
e
===
PDO
::
FETCH_ASSOC
)
{
return
$row
;
return
$row
;
}
else
if
(
$fetch
Styl
e
===
PDO
::
FETCH_NUM
)
{
}
else
if
(
$fetch
Mod
e
===
PDO
::
FETCH_NUM
)
{
return
array_values
(
$row
);
return
array_values
(
$row
);
}
else
if
(
$fetch
Styl
e
===
PDO
::
FETCH_BOTH
)
{
}
else
if
(
$fetch
Mod
e
===
PDO
::
FETCH_BOTH
)
{
return
array_merge
(
$row
,
array_values
(
$row
));
return
array_merge
(
$row
,
array_values
(
$row
));
}
else
if
(
$fetch
Styl
e
===
PDO
::
FETCH_COLUMN
)
{
}
else
if
(
$fetch
Mod
e
===
PDO
::
FETCH_COLUMN
)
{
return
reset
(
$row
);
return
reset
(
$row
);
}
else
{
}
else
{
throw
new
\InvalidArgumentException
(
"Invalid fetch-style given for fetching result."
);
throw
new
\InvalidArgumentException
(
"Invalid fetch-style given for fetching result."
);
...
@@ -82,10 +82,10 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
...
@@ -82,10 +82,10 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return
false
;
return
false
;
}
}
public
function
fetchAll
(
$fetch
Styl
e
=
null
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
)
{
{
$rows
=
array
();
$rows
=
array
();
while
(
$row
=
$this
->
fetch
(
$fetch
Styl
e
))
{
while
(
$row
=
$this
->
fetch
(
$fetch
Mod
e
))
{
$rows
[]
=
$row
;
$rows
[]
=
$row
;
}
}
return
$rows
;
return
$rows
;
...
...
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
View file @
c0533c1d
...
@@ -81,7 +81,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
...
@@ -81,7 +81,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
/**
/**
* @var int
* @var int
*/
*/
private
$defaultFetch
Styl
e
=
PDO
::
FETCH_BOTH
;
private
$defaultFetch
Mod
e
=
PDO
::
FETCH_BOTH
;
/**
/**
* @param Statement $stmt
* @param Statement $stmt
...
@@ -132,9 +132,9 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
...
@@ -132,9 +132,9 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
return
$this
->
statement
->
columnCount
();
return
$this
->
statement
->
columnCount
();
}
}
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
)
{
{
$this
->
defaultFetch
Style
=
$fetchStyl
e
;
$this
->
defaultFetch
Mode
=
$fetchMod
e
;
}
}
public
function
getIterator
()
public
function
getIterator
()
...
@@ -147,13 +147,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
...
@@ -147,13 +147,13 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
* fetch
* fetch
*
*
* @see Query::HYDRATE_* constants
* @see Query::HYDRATE_* constants
* @param integer $fetch
Style
Controls how the next row will be returned to the caller.
* @param integer $fetch
Mode
Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
* defaulting to Query::HYDRATE_BOTH
*
*
* @return mixed
* @return mixed
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
if
(
$this
->
data
===
null
)
{
if
(
$this
->
data
===
null
)
{
$this
->
data
=
array
();
$this
->
data
=
array
();
...
@@ -163,15 +163,15 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
...
@@ -163,15 +163,15 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
if
(
$row
)
{
if
(
$row
)
{
$this
->
data
[]
=
$row
;
$this
->
data
[]
=
$row
;
$fetch
Style
=
$fetchStyle
?:
$this
->
defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
defaultFetchMod
e
;
if
(
$fetch
Styl
e
==
PDO
::
FETCH_ASSOC
)
{
if
(
$fetch
Mod
e
==
PDO
::
FETCH_ASSOC
)
{
return
$row
;
return
$row
;
}
else
if
(
$fetch
Styl
e
==
PDO
::
FETCH_NUM
)
{
}
else
if
(
$fetch
Mod
e
==
PDO
::
FETCH_NUM
)
{
return
array_values
(
$row
);
return
array_values
(
$row
);
}
else
if
(
$fetch
Styl
e
==
PDO
::
FETCH_BOTH
)
{
}
else
if
(
$fetch
Mod
e
==
PDO
::
FETCH_BOTH
)
{
return
array_merge
(
$row
,
array_values
(
$row
));
return
array_merge
(
$row
,
array_values
(
$row
));
}
else
if
(
$fetch
Styl
e
==
PDO
::
FETCH_COLUMN
)
{
}
else
if
(
$fetch
Mod
e
==
PDO
::
FETCH_COLUMN
)
{
return
reset
(
$row
);
return
reset
(
$row
);
}
else
{
}
else
{
throw
new
\InvalidArgumentException
(
"Invalid fetch-style given for caching result."
);
throw
new
\InvalidArgumentException
(
"Invalid fetch-style given for caching result."
);
...
@@ -184,16 +184,16 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
...
@@ -184,16 +184,16 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
/**
/**
* Returns an array containing all of the result set rows
* Returns an array containing all of the result set rows
*
*
* @param integer $fetch
Style
Controls how the next row will be returned to the caller.
* @param integer $fetch
Mode
Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
* defaulting to Query::HYDRATE_BOTH
*
*
* @return array
* @return array
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
null
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
)
{
{
$rows
=
array
();
$rows
=
array
();
while
(
$row
=
$this
->
fetch
(
$fetch
Styl
e
))
{
while
(
$row
=
$this
->
fetch
(
$fetch
Mod
e
))
{
$rows
[]
=
$row
;
$rows
[]
=
$row
;
}
}
return
$rows
;
return
$rows
;
...
...
lib/Doctrine/DBAL/Connection.php
View file @
c0533c1d
...
@@ -173,7 +173,7 @@ class Connection implements DriverConnection
...
@@ -173,7 +173,7 @@ class Connection implements DriverConnection
*/
*/
private
$_isRollbackOnly
=
false
;
private
$_isRollbackOnly
=
false
;
private
$_defaultFetch
Styl
e
=
PDO
::
FETCH_ASSOC
;
private
$_defaultFetch
Mod
e
=
PDO
::
FETCH_ASSOC
;
/**
/**
* Initializes a new instance of the Connection class.
* Initializes a new instance of the Connection class.
...
@@ -361,11 +361,11 @@ class Connection implements DriverConnection
...
@@ -361,11 +361,11 @@ class Connection implements DriverConnection
/**
/**
* setFetchMode
* setFetchMode
*
*
* @param integer $fetch
Styl
e
* @param integer $fetch
Mod
e
*/
*/
public
function
setFetchMode
(
$fetch
Styl
e
)
public
function
setFetchMode
(
$fetch
Mod
e
)
{
{
$this
->
_defaultFetch
Style
=
$fetchStyl
e
;
$this
->
_defaultFetch
Mode
=
$fetchMod
e
;
}
}
/**
/**
...
@@ -605,7 +605,7 @@ class Connection implements DriverConnection
...
@@ -605,7 +605,7 @@ class Connection implements DriverConnection
$this
->
connect
();
$this
->
connect
();
$stmt
=
new
Statement
(
$statement
,
$this
);
$stmt
=
new
Statement
(
$statement
,
$this
);
$stmt
->
setFetchMode
(
$this
->
_defaultFetch
Styl
e
);
$stmt
->
setFetchMode
(
$this
->
_defaultFetch
Mod
e
);
return
$stmt
;
return
$stmt
;
}
}
...
@@ -650,7 +650,7 @@ class Connection implements DriverConnection
...
@@ -650,7 +650,7 @@ class Connection implements DriverConnection
$stmt
=
$this
->
_conn
->
query
(
$query
);
$stmt
=
$this
->
_conn
->
query
(
$query
);
}
}
$stmt
->
setFetchMode
(
$this
->
_defaultFetch
Styl
e
);
$stmt
->
setFetchMode
(
$this
->
_defaultFetch
Mod
e
);
if
(
$logger
)
{
if
(
$logger
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
...
@@ -691,7 +691,7 @@ class Connection implements DriverConnection
...
@@ -691,7 +691,7 @@ class Connection implements DriverConnection
$stmt
=
new
ResultCacheStatement
(
$this
->
executeQuery
(
$query
,
$params
,
$types
),
$resultCache
,
$cacheKey
,
$realKey
,
$qcp
->
getLifetime
());
$stmt
=
new
ResultCacheStatement
(
$this
->
executeQuery
(
$query
,
$params
,
$types
),
$resultCache
,
$cacheKey
,
$realKey
,
$qcp
->
getLifetime
());
}
}
$stmt
->
setFetchMode
(
$this
->
_defaultFetch
Styl
e
);
$stmt
->
setFetchMode
(
$this
->
_defaultFetch
Mod
e
);
return
$stmt
;
return
$stmt
;
}
}
...
@@ -740,7 +740,7 @@ class Connection implements DriverConnection
...
@@ -740,7 +740,7 @@ class Connection implements DriverConnection
}
}
$statement
=
call_user_func_array
(
array
(
$this
->
_conn
,
'query'
),
$args
);
$statement
=
call_user_func_array
(
array
(
$this
->
_conn
,
'query'
),
$args
);
$statement
->
setFetchMode
(
$this
->
_defaultFetch
Styl
e
);
$statement
->
setFetchMode
(
$this
->
_defaultFetch
Mod
e
);
if
(
$logger
)
{
if
(
$logger
)
{
$logger
->
stopQuery
();
$logger
->
stopQuery
();
...
...
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
View file @
c0533c1d
...
@@ -29,7 +29,7 @@ class DB2Statement implements \IteratorAggregate, Statement
...
@@ -29,7 +29,7 @@ class DB2Statement implements \IteratorAggregate, Statement
private
$_bindParam
=
array
();
private
$_bindParam
=
array
();
private
$_defaultFetch
Styl
e
=
\PDO
::
FETCH_BOTH
;
private
$_defaultFetch
Mod
e
=
\PDO
::
FETCH_BOTH
;
/**
/**
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
...
@@ -148,9 +148,9 @@ class DB2Statement implements \IteratorAggregate, Statement
...
@@ -148,9 +148,9 @@ class DB2Statement implements \IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
)
{
{
$this
->
_defaultFetch
Style
=
$fetchStyl
e
;
$this
->
_defaultFetch
Mode
=
$fetchMod
e
;
}
}
/**
/**
...
@@ -165,10 +165,10 @@ class DB2Statement implements \IteratorAggregate, Statement
...
@@ -165,10 +165,10 @@ class DB2Statement implements \IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
$fetch
Style
=
$fetchStyle
?:
$this
->
_defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
_defaultFetchMod
e
;
switch
(
$fetch
Styl
e
)
{
switch
(
$fetch
Mod
e
)
{
case
\PDO
::
FETCH_BOTH
:
case
\PDO
::
FETCH_BOTH
:
return
db2_fetch_both
(
$this
->
_stmt
);
return
db2_fetch_both
(
$this
->
_stmt
);
case
\PDO
::
FETCH_ASSOC
:
case
\PDO
::
FETCH_ASSOC
:
...
@@ -176,17 +176,17 @@ class DB2Statement implements \IteratorAggregate, Statement
...
@@ -176,17 +176,17 @@ class DB2Statement implements \IteratorAggregate, Statement
case
\PDO
::
FETCH_NUM
:
case
\PDO
::
FETCH_NUM
:
return
db2_fetch_array
(
$this
->
_stmt
);
return
db2_fetch_array
(
$this
->
_stmt
);
default
:
default
:
throw
new
DB2Exception
(
"Given Fetch-Style "
.
$fetch
Styl
e
.
" is not supported."
);
throw
new
DB2Exception
(
"Given Fetch-Style "
.
$fetch
Mod
e
.
" is not supported."
);
}
}
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
null
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
)
{
{
$rows
=
array
();
$rows
=
array
();
while
(
$row
=
$this
->
fetch
(
$fetch
Styl
e
))
{
while
(
$row
=
$this
->
fetch
(
$fetch
Mod
e
))
{
$rows
[]
=
$row
;
$rows
[]
=
$row
;
}
}
return
$rows
;
return
$rows
;
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
c0533c1d
...
@@ -60,7 +60,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
...
@@ -60,7 +60,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
*/
*/
protected
$_values
=
array
();
protected
$_values
=
array
();
protected
$_defaultFetch
Styl
e
=
PDO
::
FETCH_BOTH
;
protected
$_defaultFetch
Mod
e
=
PDO
::
FETCH_BOTH
;
public
function
__construct
(
\mysqli
$conn
,
$prepareString
)
public
function
__construct
(
\mysqli
$conn
,
$prepareString
)
{
{
...
@@ -216,7 +216,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
...
@@ -216,7 +216,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
$values
=
$this
->
_fetch
();
$values
=
$this
->
_fetch
();
if
(
null
===
$values
)
{
if
(
null
===
$values
)
{
...
@@ -227,9 +227,9 @@ class MysqliStatement implements \IteratorAggregate, Statement
...
@@ -227,9 +227,9 @@ class MysqliStatement implements \IteratorAggregate, Statement
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
throw
new
MysqliException
(
$this
->
_stmt
->
error
,
$this
->
_stmt
->
errno
);
}
}
$fetch
Style
=
$fetchStyle
?:
$this
->
_defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
_defaultFetchMod
e
;
switch
(
$fetch
Styl
e
)
{
switch
(
$fetch
Mod
e
)
{
case
PDO
::
FETCH_NUM
:
case
PDO
::
FETCH_NUM
:
return
$values
;
return
$values
;
...
@@ -242,24 +242,24 @@ class MysqliStatement implements \IteratorAggregate, Statement
...
@@ -242,24 +242,24 @@ class MysqliStatement implements \IteratorAggregate, Statement
return
$ret
;
return
$ret
;
default
:
default
:
throw
new
MysqliException
(
"Unknown fetch type '
{
$fetch
Styl
e
}
'"
);
throw
new
MysqliException
(
"Unknown fetch type '
{
$fetch
Mod
e
}
'"
);
}
}
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
null
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
)
{
{
$fetch
Style
=
$fetchStyle
?:
$this
->
_defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
_defaultFetchMod
e
;
$rows
=
array
();
$rows
=
array
();
if
(
PDO
::
FETCH_COLUMN
==
$fetch
Styl
e
)
{
if
(
PDO
::
FETCH_COLUMN
==
$fetch
Mod
e
)
{
while
((
$row
=
$this
->
fetchColumn
())
!==
false
)
{
while
((
$row
=
$this
->
fetchColumn
())
!==
false
)
{
$rows
[]
=
$row
;
$rows
[]
=
$row
;
}
}
}
else
{
}
else
{
while
((
$row
=
$this
->
fetch
(
$fetch
Styl
e
))
!==
null
)
{
while
((
$row
=
$this
->
fetch
(
$fetch
Mod
e
))
!==
null
)
{
$rows
[]
=
$row
;
$rows
[]
=
$row
;
}
}
}
}
...
@@ -328,7 +328,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
...
@@ -328,7 +328,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
*/
*/
public
function
setFetchMode
(
$fetchMode
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetchMode
,
$arg2
=
null
,
$arg3
=
null
)
{
{
$this
->
_defaultFetch
Styl
e
=
$fetchMode
;
$this
->
_defaultFetch
Mod
e
=
$fetchMode
;
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
View file @
c0533c1d
...
@@ -79,7 +79,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
...
@@ -79,7 +79,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
{
{
$args
=
func_get_args
();
$args
=
func_get_args
();
$sql
=
$args
[
0
];
$sql
=
$args
[
0
];
//$fetch
Styl
e = $args[1];
//$fetch
Mod
e = $args[1];
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
$stmt
->
execute
();
return
$stmt
;
return
$stmt
;
...
...
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
View file @
c0533c1d
...
@@ -36,14 +36,14 @@ class OCI8Statement implements \IteratorAggregate, Statement
...
@@ -36,14 +36,14 @@ class OCI8Statement implements \IteratorAggregate, Statement
protected
$_sth
;
protected
$_sth
;
protected
$_conn
;
protected
$_conn
;
protected
static
$_PARAM
=
':param'
;
protected
static
$_PARAM
=
':param'
;
protected
static
$fetch
Styl
eMap
=
array
(
protected
static
$fetch
Mod
eMap
=
array
(
PDO
::
FETCH_BOTH
=>
OCI_BOTH
,
PDO
::
FETCH_BOTH
=>
OCI_BOTH
,
PDO
::
FETCH_ASSOC
=>
OCI_ASSOC
,
PDO
::
FETCH_ASSOC
=>
OCI_ASSOC
,
PDO
::
FETCH_NUM
=>
OCI_NUM
,
PDO
::
FETCH_NUM
=>
OCI_NUM
,
PDO
::
PARAM_LOB
=>
OCI_B_BLOB
,
PDO
::
PARAM_LOB
=>
OCI_B_BLOB
,
PDO
::
FETCH_COLUMN
=>
OCI_NUM
,
PDO
::
FETCH_COLUMN
=>
OCI_NUM
,
);
);
protected
$_defaultFetch
Styl
e
=
PDO
::
FETCH_BOTH
;
protected
$_defaultFetch
Mod
e
=
PDO
::
FETCH_BOTH
;
protected
$_paramMap
=
array
();
protected
$_paramMap
=
array
();
/**
/**
...
@@ -190,9 +190,9 @@ class OCI8Statement implements \IteratorAggregate, Statement
...
@@ -190,9 +190,9 @@ class OCI8Statement implements \IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
)
{
{
$this
->
_defaultFetch
Style
=
$fetchStyl
e
;
$this
->
_defaultFetch
Mode
=
$fetchMod
e
;
}
}
/**
/**
...
@@ -207,41 +207,41 @@ class OCI8Statement implements \IteratorAggregate, Statement
...
@@ -207,41 +207,41 @@ class OCI8Statement implements \IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
$fetch
Style
=
$fetchStyle
?:
$this
->
_defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
_defaultFetchMod
e
;
if
(
!
isset
(
self
::
$fetch
StyleMap
[
$fetchStyl
e
]))
{
if
(
!
isset
(
self
::
$fetch
ModeMap
[
$fetchMod
e
]))
{
throw
new
\InvalidArgumentException
(
"Invalid fetch style: "
.
$fetch
Styl
e
);
throw
new
\InvalidArgumentException
(
"Invalid fetch style: "
.
$fetch
Mod
e
);
}
}
return
oci_fetch_array
(
$this
->
_sth
,
self
::
$fetch
StyleMap
[
$fetchStyl
e
]
|
OCI_RETURN_NULLS
|
OCI_RETURN_LOBS
);
return
oci_fetch_array
(
$this
->
_sth
,
self
::
$fetch
ModeMap
[
$fetchMod
e
]
|
OCI_RETURN_NULLS
|
OCI_RETURN_LOBS
);
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
null
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
)
{
{
$fetch
Style
=
$fetchStyle
?:
$this
->
_defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
_defaultFetchMod
e
;
if
(
!
isset
(
self
::
$fetch
StyleMap
[
$fetchStyl
e
]))
{
if
(
!
isset
(
self
::
$fetch
ModeMap
[
$fetchMod
e
]))
{
throw
new
\InvalidArgumentException
(
"Invalid fetch style: "
.
$fetch
Styl
e
);
throw
new
\InvalidArgumentException
(
"Invalid fetch style: "
.
$fetch
Mod
e
);
}
}
$result
=
array
();
$result
=
array
();
if
(
self
::
$fetch
StyleMap
[
$fetchStyl
e
]
===
OCI_BOTH
)
{
if
(
self
::
$fetch
ModeMap
[
$fetchMod
e
]
===
OCI_BOTH
)
{
while
(
$row
=
$this
->
fetch
(
$fetch
Styl
e
))
{
while
(
$row
=
$this
->
fetch
(
$fetch
Mod
e
))
{
$result
[]
=
$row
;
$result
[]
=
$row
;
}
}
}
else
{
}
else
{
$fetchStructure
=
OCI_FETCHSTATEMENT_BY_ROW
;
$fetchStructure
=
OCI_FETCHSTATEMENT_BY_ROW
;
if
(
$fetch
Styl
e
==
PDO
::
FETCH_COLUMN
)
{
if
(
$fetch
Mod
e
==
PDO
::
FETCH_COLUMN
)
{
$fetchStructure
=
OCI_FETCHSTATEMENT_BY_COLUMN
;
$fetchStructure
=
OCI_FETCHSTATEMENT_BY_COLUMN
;
}
}
oci_fetch_all
(
$this
->
_sth
,
$result
,
0
,
-
1
,
oci_fetch_all
(
$this
->
_sth
,
$result
,
0
,
-
1
,
self
::
$fetch
StyleMap
[
$fetchStyl
e
]
|
OCI_RETURN_NULLS
|
$fetchStructure
|
OCI_RETURN_LOBS
);
self
::
$fetch
ModeMap
[
$fetchMod
e
]
|
OCI_RETURN_NULLS
|
$fetchStructure
|
OCI_RETURN_LOBS
);
if
(
$fetch
Styl
e
==
PDO
::
FETCH_COLUMN
)
{
if
(
$fetch
Mod
e
==
PDO
::
FETCH_COLUMN
)
{
$result
=
$result
[
0
];
$result
=
$result
[
0
];
}
}
}
}
...
...
lib/Doctrine/DBAL/Driver/PDOStatement.php
View file @
c0533c1d
...
@@ -31,20 +31,20 @@ class PDOStatement extends \PDOStatement implements Statement
...
@@ -31,20 +31,20 @@ class PDOStatement extends \PDOStatement implements Statement
{
{
private
function
__construct
()
{}
private
function
__construct
()
{}
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
)
{
{
// This thin wrapper is necessary to shield against the weird signature
// This thin wrapper is necessary to shield against the weird signature
// of PDOStatement::setFetchMode(): even if the second and third
// of PDOStatement::setFetchMode(): even if the second and third
// parameters are optional, PHP will not let us remove it from this
// parameters are optional, PHP will not let us remove it from this
// declaration.
// declaration.
if
(
$arg2
===
null
&&
$arg3
===
null
)
{
if
(
$arg2
===
null
&&
$arg3
===
null
)
{
return
parent
::
setFetchMode
(
$fetch
Styl
e
);
return
parent
::
setFetchMode
(
$fetch
Mod
e
);
}
}
if
(
$arg3
===
null
)
{
if
(
$arg3
===
null
)
{
return
parent
::
setFetchMode
(
$fetch
Styl
e
,
$arg2
);
return
parent
::
setFetchMode
(
$fetch
Mod
e
,
$arg2
);
}
}
return
parent
::
setFetchMode
(
$fetch
Styl
e
,
$arg2
,
$arg3
);
return
parent
::
setFetchMode
(
$fetch
Mod
e
,
$arg2
,
$arg3
);
}
}
}
}
lib/Doctrine/DBAL/Driver/ResultStatement.php
View file @
c0533c1d
...
@@ -50,32 +50,32 @@ interface ResultStatement extends \Traversable
...
@@ -50,32 +50,32 @@ interface ResultStatement extends \Traversable
* setFetchMode
* setFetchMode
* Set the fetch mode to use while iterating this statement.
* Set the fetch mode to use while iterating this statement.
*
*
* @param integer $fetch
Styl
e
* @param integer $fetch
Mod
e
*/
*/
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
);
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
);
/**
/**
* fetch
* fetch
*
*
* @see Query::HYDRATE_* constants
* @see Query::HYDRATE_* constants
* @param integer $fetch
Style
Controls how the next row will be returned to the caller.
* @param integer $fetch
Mode
Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
* defaulting to Query::HYDRATE_BOTH
*
*
* @return mixed
* @return mixed
*/
*/
function
fetch
(
$fetch
Styl
e
=
null
);
function
fetch
(
$fetch
Mod
e
=
null
);
/**
/**
* Returns an array containing all of the result set rows
* Returns an array containing all of the result set rows
*
*
* @param integer $fetch
Style
Controls how the next row will be returned to the caller.
* @param integer $fetch
Mode
Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
* defaulting to Query::HYDRATE_BOTH
*
*
* @return array
* @return array
*/
*/
function
fetchAll
(
$fetch
Styl
e
=
null
);
function
fetchAll
(
$fetch
Mod
e
=
null
);
/**
/**
* fetchColumn
* fetchColumn
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
View file @
c0533c1d
...
@@ -75,7 +75,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -75,7 +75,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*
*
* @param int
* @param int
*/
*/
private
$defaultFetch
Styl
e
=
PDO
::
FETCH_BOTH
;
private
$defaultFetch
Mod
e
=
PDO
::
FETCH_BOTH
;
/**
/**
* @var int|null
* @var int|null
...
@@ -175,9 +175,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -175,9 +175,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
}
}
}
}
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
)
{
{
$this
->
defaultFetch
Style
=
$fetchStyl
e
;
$this
->
defaultFetch
Mode
=
$fetchMod
e
;
}
}
/**
/**
...
@@ -192,12 +192,12 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -192,12 +192,12 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
$fetch
Style
=
$fetchStyle
?:
$this
->
defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
defaultFetchMod
e
;
if
(
isset
(
self
::
$fetchMap
[
$fetch
Styl
e
]))
{
if
(
isset
(
self
::
$fetchMap
[
$fetch
Mod
e
]))
{
return
sqlsrv_fetch_array
(
$this
->
stmt
,
self
::
$fetchMap
[
$fetch
Styl
e
]);
return
sqlsrv_fetch_array
(
$this
->
stmt
,
self
::
$fetchMap
[
$fetch
Mod
e
]);
}
else
if
(
$fetch
Style
==
PDO
::
FETCH_OBJ
||
$fetchStyl
e
==
PDO
::
FETCH_CLASS
)
{
}
else
if
(
$fetch
Mode
==
PDO
::
FETCH_OBJ
||
$fetchMod
e
==
PDO
::
FETCH_CLASS
)
{
$className
=
null
;
$className
=
null
;
$ctorArgs
=
null
;
$ctorArgs
=
null
;
if
(
func_num_args
()
>=
2
)
{
if
(
func_num_args
()
>=
2
)
{
...
@@ -214,7 +214,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -214,7 +214,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
null
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
)
{
{
$className
=
null
;
$className
=
null
;
$ctorArgs
=
null
;
$ctorArgs
=
null
;
...
@@ -225,7 +225,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
...
@@ -225,7 +225,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
}
}
$rows
=
array
();
$rows
=
array
();
while
(
$row
=
$this
->
fetch
(
$fetch
Styl
e
,
$className
,
$ctorArgs
))
{
while
(
$row
=
$this
->
fetch
(
$fetch
Mod
e
,
$className
,
$ctorArgs
))
{
$rows
[]
=
$row
;
$rows
[]
=
$row
;
}
}
return
$rows
;
return
$rows
;
...
...
lib/Doctrine/DBAL/Portability/Statement.php
View file @
c0533c1d
...
@@ -51,7 +51,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
...
@@ -51,7 +51,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
/**
/**
* @var int
* @var int
*/
*/
private
$defaultFetch
Styl
e
=
PDO
::
FETCH_BOTH
;
private
$defaultFetch
Mod
e
=
PDO
::
FETCH_BOTH
;
/**
/**
* Wraps <tt>Statement</tt> and applies portability measures
* Wraps <tt>Statement</tt> and applies portability measures
...
@@ -101,10 +101,10 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
...
@@ -101,10 +101,10 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
return
$this
->
stmt
->
execute
(
$params
);
return
$this
->
stmt
->
execute
(
$params
);
}
}
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg1
=
null
,
$arg2
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg1
=
null
,
$arg2
=
null
)
{
{
$this
->
defaultFetch
Style
=
$fetchStyl
e
;
$this
->
defaultFetch
Mode
=
$fetchMod
e
;
$this
->
stmt
->
setFetchMode
(
$fetch
Styl
e
,
$arg1
,
$arg2
);
$this
->
stmt
->
setFetchMode
(
$fetch
Mod
e
,
$arg1
,
$arg2
);
}
}
public
function
getIterator
()
public
function
getIterator
()
...
@@ -113,32 +113,32 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
...
@@ -113,32 +113,32 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
return
new
\ArrayIterator
(
$data
);
return
new
\ArrayIterator
(
$data
);
}
}
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
$fetch
Style
=
$fetchStyle
?:
$this
->
defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
defaultFetchMod
e
;
$row
=
$this
->
stmt
->
fetch
(
$fetch
Styl
e
);
$row
=
$this
->
stmt
->
fetch
(
$fetch
Mod
e
);
$row
=
$this
->
fixRow
(
$row
,
$row
=
$this
->
fixRow
(
$row
,
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
),
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
),
!
is_null
(
$this
->
case
)
&&
(
$fetch
Style
==
PDO
::
FETCH_ASSOC
||
$fetchStyl
e
==
PDO
::
FETCH_BOTH
)
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
)
!
is_null
(
$this
->
case
)
&&
(
$fetch
Mode
==
PDO
::
FETCH_ASSOC
||
$fetchMod
e
==
PDO
::
FETCH_BOTH
)
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
)
);
);
return
$row
;
return
$row
;
}
}
public
function
fetchAll
(
$fetch
Styl
e
=
null
,
$columnIndex
=
0
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
,
$columnIndex
=
0
)
{
{
$fetch
Style
=
$fetchStyle
?:
$this
->
defaultFetchStyl
e
;
$fetch
Mode
=
$fetchMode
?:
$this
->
defaultFetchMod
e
;
if
(
$columnIndex
!=
0
)
{
if
(
$columnIndex
!=
0
)
{
$rows
=
$this
->
stmt
->
fetchAll
(
$fetch
Styl
e
,
$columnIndex
);
$rows
=
$this
->
stmt
->
fetchAll
(
$fetch
Mod
e
,
$columnIndex
);
}
else
{
}
else
{
$rows
=
$this
->
stmt
->
fetchAll
(
$fetch
Styl
e
);
$rows
=
$this
->
stmt
->
fetchAll
(
$fetch
Mod
e
);
}
}
$iterateRow
=
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
);
$iterateRow
=
$this
->
portability
&
(
Connection
::
PORTABILITY_EMPTY_TO_NULL
|
Connection
::
PORTABILITY_RTRIM
);
$fixCase
=
!
is_null
(
$this
->
case
)
&&
(
$fetch
Style
==
PDO
::
FETCH_ASSOC
||
$fetchStyl
e
==
PDO
::
FETCH_BOTH
)
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
);
$fixCase
=
!
is_null
(
$this
->
case
)
&&
(
$fetch
Mode
==
PDO
::
FETCH_ASSOC
||
$fetchMod
e
==
PDO
::
FETCH_BOTH
)
&&
(
$this
->
portability
&
Connection
::
PORTABILITY_FIX_CASE
);
if
(
!
$iterateRow
&&
!
$fixCase
)
{
if
(
!
$iterateRow
&&
!
$fixCase
)
{
return
$rows
;
return
$rows
;
}
}
...
...
lib/Doctrine/DBAL/Statement.php
View file @
c0533c1d
...
@@ -184,9 +184,9 @@ class Statement implements \IteratorAggregate, DriverStatement
...
@@ -184,9 +184,9 @@ class Statement implements \IteratorAggregate, DriverStatement
return
$this
->
stmt
->
errorInfo
();
return
$this
->
stmt
->
errorInfo
();
}
}
public
function
setFetchMode
(
$fetch
Styl
e
,
$arg2
=
null
,
$arg3
=
null
)
public
function
setFetchMode
(
$fetch
Mod
e
,
$arg2
=
null
,
$arg3
=
null
)
{
{
return
$this
->
stmt
->
setFetchMode
(
$fetch
Styl
e
,
$arg2
,
$arg3
);
return
$this
->
stmt
->
setFetchMode
(
$fetch
Mod
e
,
$arg2
,
$arg3
);
}
}
public
function
getIterator
()
public
function
getIterator
()
...
@@ -197,28 +197,28 @@ class Statement implements \IteratorAggregate, DriverStatement
...
@@ -197,28 +197,28 @@ class Statement implements \IteratorAggregate, DriverStatement
/**
/**
* Fetches the next row from a result set.
* Fetches the next row from a result set.
*
*
* @param integer $fetch
Styl
e
* @param integer $fetch
Mod
e
* @return mixed The return value of this function on success depends on the fetch type.
* @return mixed The return value of this function on success depends on the fetch type.
* In all cases, FALSE is returned on failure.
* In all cases, FALSE is returned on failure.
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
return
$this
->
stmt
->
fetch
(
$fetch
Styl
e
);
return
$this
->
stmt
->
fetch
(
$fetch
Mod
e
);
}
}
/**
/**
* Returns an array containing all of the result set rows.
* Returns an array containing all of the result set rows.
*
*
* @param integer $fetch
Styl
e
* @param integer $fetch
Mod
e
* @param mixed $fetchArgument
* @param mixed $fetchArgument
* @return array An array containing all of the remaining rows in the result set.
* @return array An array containing all of the remaining rows in the result set.
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
null
,
$fetchArgument
=
0
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
,
$fetchArgument
=
0
)
{
{
if
(
$fetchArgument
!==
0
)
{
if
(
$fetchArgument
!==
0
)
{
return
$this
->
stmt
->
fetchAll
(
$fetch
Styl
e
,
$fetchArgument
);
return
$this
->
stmt
->
fetchAll
(
$fetch
Mod
e
,
$fetchArgument
);
}
}
return
$this
->
stmt
->
fetchAll
(
$fetch
Styl
e
);
return
$this
->
stmt
->
fetchAll
(
$fetch
Mod
e
);
}
}
/**
/**
...
...
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
View file @
c0533c1d
...
@@ -101,13 +101,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -101,13 +101,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertStandardAndIteratorFetchAreEqual
(
\PDO
::
FETCH_NUM
);
$this
->
assertStandardAndIteratorFetchAreEqual
(
\PDO
::
FETCH_NUM
);
}
}
public
function
assertStandardAndIteratorFetchAreEqual
(
$fetch
Styl
e
)
public
function
assertStandardAndIteratorFetchAreEqual
(
$fetch
Mod
e
)
{
{
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetch
Styl
e
);
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetch
Mod
e
);
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data_iterator
=
$this
->
hydrateStmtIterator
(
$stmt
,
$fetch
Styl
e
);
$data_iterator
=
$this
->
hydrateStmtIterator
(
$stmt
,
$fetch
Mod
e
);
$this
->
assertEquals
(
$data
,
$data_iterator
);
$this
->
assertEquals
(
$data
,
$data_iterator
);
}
}
...
@@ -145,18 +145,18 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -145,18 +145,18 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertEquals
(
2
,
count
(
$this
->
sqlLogger
->
queries
));
$this
->
assertEquals
(
2
,
count
(
$this
->
sqlLogger
->
queries
));
}
}
public
function
assertCacheNonCacheSelectSameFetchModeAreEqual
(
$expectedResult
,
$fetch
Styl
e
)
public
function
assertCacheNonCacheSelectSameFetchModeAreEqual
(
$expectedResult
,
$fetch
Mod
e
)
{
{
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$this
->
assertEquals
(
2
,
$stmt
->
columnCount
());
$this
->
assertEquals
(
2
,
$stmt
->
columnCount
());
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetch
Styl
e
);
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetch
Mod
e
);
$this
->
assertEquals
(
$expectedResult
,
$data
);
$this
->
assertEquals
(
$expectedResult
,
$data
);
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching ORDER BY test_int ASC"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$this
->
assertEquals
(
2
,
$stmt
->
columnCount
());
$this
->
assertEquals
(
2
,
$stmt
->
columnCount
());
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetch
Styl
e
);
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetch
Mod
e
);
$this
->
assertEquals
(
$expectedResult
,
$data
);
$this
->
assertEquals
(
$expectedResult
,
$data
);
$this
->
assertEquals
(
1
,
count
(
$this
->
sqlLogger
->
queries
),
"just one dbal hit"
);
$this
->
assertEquals
(
1
,
count
(
$this
->
sqlLogger
->
queries
),
"just one dbal hit"
);
}
}
...
@@ -185,20 +185,20 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -185,20 +185,20 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertEquals
(
1
,
count
(
$secondCache
->
fetch
(
"emptycachekey"
)));
$this
->
assertEquals
(
1
,
count
(
$secondCache
->
fetch
(
"emptycachekey"
)));
}
}
private
function
hydrateStmt
(
$stmt
,
$fetch
Styl
e
=
\PDO
::
FETCH_ASSOC
)
private
function
hydrateStmt
(
$stmt
,
$fetch
Mod
e
=
\PDO
::
FETCH_ASSOC
)
{
{
$data
=
array
();
$data
=
array
();
while
(
$row
=
$stmt
->
fetch
(
$fetch
Styl
e
))
{
while
(
$row
=
$stmt
->
fetch
(
$fetch
Mod
e
))
{
$data
[]
=
is_array
(
$row
)
?
array_change_key_case
(
$row
,
CASE_LOWER
)
:
$row
;
$data
[]
=
is_array
(
$row
)
?
array_change_key_case
(
$row
,
CASE_LOWER
)
:
$row
;
}
}
$stmt
->
closeCursor
();
$stmt
->
closeCursor
();
return
$data
;
return
$data
;
}
}
private
function
hydrateStmtIterator
(
$stmt
,
$fetch
Styl
e
=
\PDO
::
FETCH_ASSOC
)
private
function
hydrateStmtIterator
(
$stmt
,
$fetch
Mod
e
=
\PDO
::
FETCH_ASSOC
)
{
{
$data
=
array
();
$data
=
array
();
$stmt
->
setFetchMode
(
$fetch
Styl
e
);
$stmt
->
setFetchMode
(
$fetch
Mod
e
);
foreach
(
$stmt
as
$row
)
{
foreach
(
$stmt
as
$row
)
{
$data
[]
=
is_array
(
$row
)
?
array_change_key_case
(
$row
,
CASE_LOWER
)
:
$row
;
$data
[]
=
is_array
(
$row
)
?
array_change_key_case
(
$row
,
CASE_LOWER
)
:
$row
;
}
}
...
...
tests/Doctrine/Tests/Mocks/HydratorMockStatement.php
View file @
c0533c1d
...
@@ -27,7 +27,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
...
@@ -27,7 +27,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
*
*
* @return array
* @return array
*/
*/
public
function
fetchAll
(
$fetch
Styl
e
=
null
,
$columnIndex
=
null
,
array
$ctorArgs
=
null
)
public
function
fetchAll
(
$fetch
Mod
e
=
null
,
$columnIndex
=
null
,
array
$ctorArgs
=
null
)
{
{
return
$this
->
_resultSet
;
return
$this
->
_resultSet
;
}
}
...
@@ -44,7 +44,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
...
@@ -44,7 +44,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
* Fetches the next row in the result set.
* Fetches the next row in the result set.
*
*
*/
*/
public
function
fetch
(
$fetch
Styl
e
=
null
)
public
function
fetch
(
$fetch
Mod
e
=
null
)
{
{
$current
=
current
(
$this
->
_resultSet
);
$current
=
current
(
$this
->
_resultSet
);
next
(
$this
->
_resultSet
);
next
(
$this
->
_resultSet
);
...
...
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