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
a6d6962e
Commit
a6d6962e
authored
Feb 09, 2017
by
Sergei Morozov
Committed by
Marco Pivetta
Feb 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-2644] Fix fetchAll(PDO::FETCH_COLUMN) on DB2 with Portability wrapper
parent
a8447cb8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
3 deletions
+50
-3
Connection.php
lib/Doctrine/DBAL/Portability/Connection.php
+3
-3
Statement.php
lib/Doctrine/DBAL/Portability/Statement.php
+12
-0
PortabilityTest.php
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
+35
-0
No files found.
lib/Doctrine/DBAL/Portability/Connection.php
View file @
a6d6962e
...
@@ -71,11 +71,11 @@ class Connection extends \Doctrine\DBAL\Connection
...
@@ -71,11 +71,11 @@ class Connection extends \Doctrine\DBAL\Connection
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
"sqlite"
)
{
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
"sqlite"
)
{
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLITE
;
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLITE
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
"drizzle"
)
{
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
"drizzle"
)
{
$params
[
'portability'
]
=
self
::
PORTABILITY_DRIZZLE
;
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_DRIZZLE
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'sqlanywhere'
)
{
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'sqlanywhere'
)
{
$params
[
'portability'
]
=
self
::
PORTABILITY_SQLANYWHERE
;
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLANYWHERE
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'db2'
)
{
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'db2'
)
{
$params
[
'portability'
]
=
self
::
PORTABILITY_DB2
;
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_DB2
;
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'mssql'
)
{
}
elseif
(
$this
->
getDatabasePlatform
()
->
getName
()
===
'mssql'
)
{
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLSRV
;
$params
[
'portability'
]
=
$params
[
'portability'
]
&
self
::
PORTABILITY_SQLSRV
;
}
else
{
}
else
{
...
...
lib/Doctrine/DBAL/Portability/Statement.php
View file @
a6d6962e
...
@@ -175,10 +175,22 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
...
@@ -175,10 +175,22 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
return
$rows
;
return
$rows
;
}
}
if
(
$fetchMode
===
PDO
::
FETCH_COLUMN
)
{
foreach
(
$rows
as
$num
=>
$row
)
{
$rows
[
$num
]
=
array
(
$row
);
}
}
foreach
(
$rows
as
$num
=>
$row
)
{
foreach
(
$rows
as
$num
=>
$row
)
{
$rows
[
$num
]
=
$this
->
fixRow
(
$row
,
$iterateRow
,
$fixCase
);
$rows
[
$num
]
=
$this
->
fixRow
(
$row
,
$iterateRow
,
$fixCase
);
}
}
if
(
$fetchMode
===
PDO
::
FETCH_COLUMN
)
{
foreach
(
$rows
as
$num
=>
$row
)
{
$rows
[
$num
]
=
$row
[
0
];
}
}
return
$rows
;
return
$rows
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
View file @
a6d6962e
...
@@ -144,4 +144,39 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -144,4 +144,39 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertEquals
(
$portability
,
$connection
->
getPortability
());
$this
->
assertEquals
(
$portability
,
$connection
->
getPortability
());
}
}
/**
* @dataProvider fetchAllColumnProvider
*/
public
function
testFetchAllColumn
(
$field
,
array
$expected
)
{
$conn
=
$this
->
getPortableConnection
();
$stmt
=
$conn
->
query
(
'SELECT '
.
$field
.
' FROM portability_table'
);
$column
=
$stmt
->
fetchAll
(
PDO
::
FETCH_COLUMN
);
$this
->
assertEquals
(
$expected
,
$column
);
}
public
static
function
fetchAllColumnProvider
()
{
return
array
(
'int'
=>
array
(
'Test_Int'
,
array
(
1
,
2
),
),
'string'
=>
array
(
'Test_String'
,
array
(
'foo'
,
'foo'
),
),
);
}
public
function
testFetchAllNullColumn
()
{
$conn
=
$this
->
getPortableConnection
();
$stmt
=
$conn
->
query
(
'SELECT Test_Null FROM portability_table'
);
$column
=
$stmt
->
fetchAll
(
PDO
::
FETCH_COLUMN
);
$this
->
assertSame
(
array
(
null
,
null
),
$column
);
}
}
}
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