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
3505a5ed
Commit
3505a5ed
authored
Jun 24, 2017
by
Ian Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
An example of a PDOIterator which can be rewound .
parent
0ebafdbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
Connection.php
lib/Doctrine/DBAL/Connection.php
+2
-1
PDOStatementIterator.php
lib/Doctrine/DBAL/Driver/PDOStatementIterator.php
+55
-0
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
3505a5ed
...
...
@@ -19,6 +19,7 @@
namespace
Doctrine\DBAL
;
use
Doctrine\DBAL\Driver\PDOStatementIterator
;
use
Doctrine\DBAL\Driver\ServerInfoAwareConnection
;
use
Doctrine\DBAL\Exception\InvalidArgumentException
;
use
PDO
;
...
...
@@ -1033,7 +1034,7 @@ class Connection implements DriverConnection
$logger
->
stopQuery
();
}
return
$statement
;
return
new
PDOStatementIterator
(
$statement
)
;
}
/**
...
...
lib/Doctrine/DBAL/Driver/PDOStatementIterator.php
0 → 100644
View file @
3505a5ed
<?php
namespace
Doctrine\DBAL\Driver
;
class
PDOStatementIterator
implements
\Iterator
{
public
$stmt
;
public
$cache
;
public
$position
=
0
;
public
function
__construct
(
\PDOStatement
$stmt
)
{
$this
->
cache
=
[];
$this
->
position
=
0
;
$this
->
stmt
=
$stmt
;
$this
->
next
();
}
public
function
rewind
()
{
$this
->
position
=
0
;
}
public
function
valid
()
{
return
isset
(
$this
->
cache
[
$this
->
position
]);
}
public
function
current
()
{
return
$this
->
cache
[
$this
->
position
];
}
public
function
key
()
{
return
$this
->
position
;
}
public
function
next
()
{
if
(
$this
->
valid
())
{
$this
->
cache
[
$this
->
position
];
$this
->
position
++
;
}
else
{
$this
->
cache
[
$this
->
position
]
=
$this
->
stmt
->
fetch
();
$this
->
position
++
;
}
}
public
function
__call
(
$name
,
$arguments
)
{
return
call_user_func_array
([
$this
->
stmt
,
$name
],
$arguments
);
}
}
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