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
4fa2fa4d
Commit
4fa2fa4d
authored
Aug 10, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-568' into 2.4
parents
3253f7a1
5c305a9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
12 deletions
+57
-12
Connection.php
lib/Doctrine/DBAL/Connection.php
+6
-6
Connection.php
lib/Doctrine/DBAL/Portability/Connection.php
+18
-3
PortabilityTest.php
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
+33
-3
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
4fa2fa4d
...
...
@@ -177,7 +177,7 @@ class Connection implements DriverConnection
/**
* @var integer
*/
pr
ivate
$_
defaultFetchMode
=
PDO
::
FETCH_ASSOC
;
pr
otected
$
defaultFetchMode
=
PDO
::
FETCH_ASSOC
;
/**
* Initializes a new instance of the Connection class.
...
...
@@ -373,7 +373,7 @@ class Connection implements DriverConnection
*/
public
function
setFetchMode
(
$fetchMode
)
{
$this
->
_
defaultFetchMode
=
$fetchMode
;
$this
->
defaultFetchMode
=
$fetchMode
;
}
/**
...
...
@@ -648,7 +648,7 @@ class Connection implements DriverConnection
throw
DBALException
::
driverExceptionDuringQuery
(
$ex
,
$statement
);
}
$stmt
->
setFetchMode
(
$this
->
_
defaultFetchMode
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
return
$stmt
;
}
...
...
@@ -701,7 +701,7 @@ class Connection implements DriverConnection
throw
DBALException
::
driverExceptionDuringQuery
(
$ex
,
$query
,
$this
->
resolveParams
(
$params
,
$types
));
}
$stmt
->
setFetchMode
(
$this
->
_
defaultFetchMode
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
if
(
$logger
)
{
$logger
->
stopQuery
();
...
...
@@ -745,7 +745,7 @@ class Connection implements DriverConnection
$stmt
=
new
ResultCacheStatement
(
$this
->
executeQuery
(
$query
,
$params
,
$types
),
$resultCache
,
$cacheKey
,
$realKey
,
$qcp
->
getLifetime
());
}
$stmt
->
setFetchMode
(
$this
->
_
defaultFetchMode
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
return
$stmt
;
}
...
...
@@ -810,7 +810,7 @@ class Connection implements DriverConnection
throw
DBALException
::
driverExceptionDuringQuery
(
$ex
,
$args
[
0
]);
}
$statement
->
setFetchMode
(
$this
->
_
defaultFetchMode
);
$statement
->
setFetchMode
(
$this
->
defaultFetchMode
);
if
(
$logger
)
{
$logger
->
stopQuery
();
...
...
lib/Doctrine/DBAL/Portability/Connection.php
View file @
4fa2fa4d
...
...
@@ -22,6 +22,13 @@ namespace Doctrine\DBAL\Portability;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Cache\QueryCacheProfile
;
/**
* Portability wrapper for a Connection.
*
* @link www.doctrine-project.org
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class
Connection
extends
\Doctrine\DBAL\Connection
{
const
PORTABILITY_ALL
=
255
;
...
...
@@ -105,7 +112,10 @@ class Connection extends \Doctrine\DBAL\Connection
*/
public
function
executeQuery
(
$query
,
array
$params
=
array
(),
$types
=
array
(),
QueryCacheProfile
$qcp
=
null
)
{
return
new
Statement
(
parent
::
executeQuery
(
$query
,
$params
,
$types
,
$qcp
),
$this
);
$stmt
=
new
Statement
(
parent
::
executeQuery
(
$query
,
$params
,
$types
,
$qcp
),
$this
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
return
$stmt
;
}
/**
...
...
@@ -113,7 +123,10 @@ class Connection extends \Doctrine\DBAL\Connection
*/
public
function
prepare
(
$statement
)
{
return
new
Statement
(
parent
::
prepare
(
$statement
),
$this
);
$stmt
=
new
Statement
(
parent
::
prepare
(
$statement
),
$this
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
return
$stmt
;
}
/**
...
...
@@ -124,7 +137,9 @@ class Connection extends \Doctrine\DBAL\Connection
$this
->
connect
();
$stmt
=
call_user_func_array
(
array
(
$this
->
_conn
,
'query'
),
func_get_args
());
$stmt
=
new
Statement
(
$stmt
,
$this
);
$stmt
->
setFetchMode
(
$this
->
defaultFetchMode
);
return
new
Statement
(
$stmt
,
$this
)
;
return
$stmt
;
}
}
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
View file @
4fa2fa4d
...
...
@@ -25,6 +25,11 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
}
}
/**
* @param integer $portabilityMode
* @param integer $case
* @return Connection
*/
private
function
getPortableConnection
(
$portabilityMode
=
\Doctrine\DBAL\Portability\Connection
::
PORTABILITY_ALL
,
$case
=
\PDO
::
CASE_LOWER
)
{
if
(
!
$this
->
portableConnection
)
{
...
...
@@ -67,18 +72,42 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
}
$stmt
=
$this
->
getPortableConnection
()
->
query
(
'SELECT * FROM portability_table'
);
while
(
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
))
{
while
(
(
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
)
))
{
$this
->
assertFetchResultRow
(
$row
);
}
$stmt
=
$this
->
getPortableConnection
()
->
prepare
(
'SELECT * FROM portability_table'
);
$stmt
->
execute
();
while
(
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
))
{
while
((
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
)))
{
$this
->
assertFetchResultRow
(
$row
);
}
}
public
function
testConnFetchMode
()
{
$conn
=
$this
->
getPortableConnection
();
$conn
->
setFetchMode
(
\PDO
::
FETCH_ASSOC
);
$rows
=
$conn
->
fetchAll
(
'SELECT * FROM portability_table'
);
$this
->
assertFetchResultRows
(
$rows
);
$stmt
=
$conn
->
query
(
'SELECT * FROM portability_table'
);
foreach
(
$stmt
as
$row
)
{
$this
->
assertFetchResultRow
(
$row
);
}
$stmt
=
$conn
->
query
(
'SELECT * FROM portability_table'
);
while
((
$row
=
$stmt
->
fetch
()))
{
$this
->
assertFetchResultRow
(
$row
);
}
$stmt
=
$conn
->
prepare
(
'SELECT * FROM portability_table'
);
$stmt
->
execute
();
while
((
$row
=
$stmt
->
fetch
()))
{
$this
->
assertFetchResultRow
(
$row
);
}
}
public
function
assertFetchResultRows
(
$rows
)
{
$this
->
assertEquals
(
2
,
count
(
$rows
));
...
...
@@ -93,5 +122,6 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertArrayHasKey
(
'test_string'
,
$row
,
"Case should be lowered."
);
$this
->
assertEquals
(
3
,
strlen
(
$row
[
'test_string'
]),
"test_string should be rtrimed to length of three for CHAR(32) column."
);
$this
->
assertNull
(
$row
[
'test_null'
]);
$this
->
assertArrayNotHasKey
(
0
,
$row
,
"PDO::FETCH_ASSOC should not return numerical keys."
);
}
}
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