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
c89b70f4
Commit
c89b70f4
authored
May 04, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #128 from gedrox/DBAL-249
[DBAL-249] result cache with fetch type PDO::FETCH_COLUMN
parents
86a0b520
5e4b1a20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
ArrayStatement.php
lib/Doctrine/DBAL/Cache/ArrayStatement.php
+4
-0
ResultCacheStatement.php
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+2
-0
ResultCacheTest.php
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
+11
-2
No files found.
lib/Doctrine/DBAL/Cache/ArrayStatement.php
View file @
c89b70f4
...
...
@@ -68,6 +68,10 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return
array_values
(
$row
);
}
else
if
(
$fetchStyle
===
PDO
::
FETCH_BOTH
)
{
return
array_merge
(
$row
,
array_values
(
$row
));
}
else
if
(
$fetchStyle
===
PDO
::
FETCH_COLUMN
)
{
return
reset
(
$row
);
}
else
{
throw
new
\InvalidArgumentException
(
"Invalid fetch-style given for fetching result."
);
}
}
return
false
;
...
...
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
View file @
c89b70f4
...
...
@@ -169,6 +169,8 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
return
array_values
(
$row
);
}
else
if
(
$fetchStyle
==
PDO
::
FETCH_BOTH
)
{
return
array_merge
(
$row
,
array_values
(
$row
));
}
else
if
(
$fetchStyle
==
PDO
::
FETCH_COLUMN
)
{
return
reset
(
$row
);
}
else
{
throw
new
\InvalidArgumentException
(
"Invalid fetch-style given for caching result."
);
}
...
...
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
View file @
c89b70f4
...
...
@@ -65,6 +65,15 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
}
$this
->
assertCacheNonCacheSelectSameFetchModeAreEqual
(
$expectedResult
,
\PDO
::
FETCH_BOTH
);
}
public
function
testFetchColumn
()
{
$expectedResult
=
array
();
foreach
(
$this
->
expectedResult
AS
$v
)
{
$expectedResult
[]
=
array_shift
(
$v
);
}
$this
->
assertCacheNonCacheSelectSameFetchModeAreEqual
(
$expectedResult
,
\PDO
::
FETCH_COLUMN
);
}
public
function
testMixingFetch
()
{
...
...
@@ -180,7 +189,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
$data
=
array
();
while
(
$row
=
$stmt
->
fetch
(
$fetchStyle
))
{
$data
[]
=
array_change_key_case
(
$row
,
CASE_LOWER
)
;
$data
[]
=
is_array
(
$row
)
?
array_change_key_case
(
$row
,
CASE_LOWER
)
:
$row
;
}
$stmt
->
closeCursor
();
return
$data
;
...
...
@@ -191,7 +200,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$data
=
array
();
$stmt
->
setFetchMode
(
$fetchStyle
);
foreach
(
$stmt
as
$row
)
{
$data
[]
=
array_change_key_case
(
$row
,
CASE_LOWER
)
;
$data
[]
=
is_array
(
$row
)
?
array_change_key_case
(
$row
,
CASE_LOWER
)
:
$row
;
}
$stmt
->
closeCursor
();
return
$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