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
149899ea
Commit
149899ea
authored
May 17, 2017
by
Ian Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use generators over iterators so can easily reuse fetch methods.
parent
048cb6ef
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
15 additions
and
171 deletions
+15
-171
AbstractIterator.php
lib/Doctrine/DBAL/Driver/AbstractIterator.php
+0
-51
DB2Iterator.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Iterator.php
+0
-26
DB2Statement.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
+3
-1
MysqliStatement.php
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
+3
-3
OCI8Iterator.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Iterator.php
+0
-46
OCI8Statement.php
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
+3
-1
SQLAnywhereIterator.php
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereIterator.php
+0
-28
SQLAnywhereStatement.php
...Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
+3
-1
SQLSrvIterator.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvIterator.php
+0
-13
SQLSrvStatement.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+3
-1
No files found.
lib/Doctrine/DBAL/Driver/AbstractIterator.php
deleted
100644 → 0
View file @
048cb6ef
<?php
namespace
Doctrine\DBAL\Driver
;
abstract
class
AbstractIterator
{
protected
$cursor
;
protected
$key
;
protected
$current
;
protected
$fetched
=
0
;
protected
$defaultFetchMode
;
public
function
__construct
(
$cursor
,
$defaultFetchMode
=
\PDO
::
FETCH_BOTH
)
{
$this
->
cursor
=
$cursor
;
$this
->
defaultFetchMode
=
$defaultFetchMode
;
$this
->
next
();
}
public
function
current
()
{
return
$this
->
current
;
}
public
function
next
()
{
$this
->
key
=
$this
->
fetched
;
$this
->
current
=
$this
->
fetch
();
if
(
$this
->
current
)
{
$this
->
fetched
++
;
}
}
public
function
key
()
{
return
$this
->
key
;
}
public
function
valid
()
{
return
(
bool
)
$this
->
current
;
}
public
function
rewind
()
{
// Not supported
}
abstract
protected
function
fetch
();
}
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Iterator.php
deleted
100644 → 0
View file @
048cb6ef
<?php
namespace
Doctrine\DBAL\Driver\IBMDB2
;
use
Doctrine\DBAL\Driver\AbstractIterator
;
class
DB2Iterator
extends
AbstractIterator
implements
\Iterator
{
protected
function
fetch
()
{
switch
(
$this
->
defaultFetchMode
)
{
case
\PDO
::
FETCH_BOTH
:
return
db2_fetch_both
(
$this
->
cursor
);
case
\PDO
::
FETCH_ASSOC
:
return
db2_fetch_assoc
(
$this
->
cursor
);
case
\PDO
::
FETCH_CLASS
:
return
db2_fetch_object
(
$this
->
cursor
);
case
\PDO
::
FETCH_NUM
:
return
db2_fetch_array
(
$this
->
cursor
);
case
\PDO
::
FETCH_OBJ
:
return
db2_fetch_object
(
$this
->
cursor
);
default
:
throw
new
DB2Exception
(
"Given Fetch-Style "
.
$this
->
defaultFetchMode
.
" is not supported."
);
}
}
}
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
View file @
149899ea
...
...
@@ -199,7 +199,9 @@ class DB2Statement implements \IteratorAggregate, Statement
*/
public
function
getIterator
()
{
return
new
DB2Iterator
(
$this
->
_stmt
,
$this
->
_defaultFetchMode
);
while
(
$row
=
$this
->
fetch
())
{
yield
$row
;
}
}
/**
...
...
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
View file @
149899ea
...
...
@@ -406,8 +406,8 @@ class MysqliStatement implements \IteratorAggregate, Statement
*/
public
function
getIterator
()
{
$data
=
$this
->
fetchAll
();
return
new
\ArrayIterator
(
$data
);
while
(
$row
=
$this
->
fetch
())
{
yield
$row
;
}
}
}
lib/Doctrine/DBAL/Driver/OCI8/OCI8Iterator.php
deleted
100644 → 0
View file @
048cb6ef
<?php
namespace
Doctrine\DBAL\Driver\OCI8
;
use
Doctrine\DBAL\Driver\AbstractIterator
;
class
OCI8Iterator
extends
AbstractIterator
implements
\Iterator
{
private
static
$fetchModeMap
=
array
(
\PDO
::
FETCH_BOTH
=>
OCI_BOTH
,
\PDO
::
FETCH_ASSOC
=>
OCI_ASSOC
,
\PDO
::
FETCH_NUM
=>
OCI_NUM
,
\PDO
::
FETCH_COLUMN
=>
OCI_NUM
,
);
protected
function
fetch
()
{
$result
=
[];
if
(
\PDO
::
FETCH_OBJ
===
$this
->
defaultFetchMode
)
{
return
oci_fetch_object
(
$this
->
cursor
);
}
if
(
self
::
$fetchModeMap
[
$this
->
defaultFetchMode
]
===
OCI_BOTH
)
{
return
oci_fetch_array
(
$this
->
cursor
,
$this
->
defaultFetchMode
|
OCI_RETURN_NULLS
|
OCI_RETURN_LOBS
);
}
$fetchStructure
=
OCI_FETCHSTATEMENT_BY_ROW
;
if
(
$this
->
defaultFetchMode
===
\PDO
::
FETCH_COLUMN
)
{
$fetchStructure
=
OCI_FETCHSTATEMENT_BY_COLUMN
;
}
oci_fetch_all
(
$this
->
cursor
,
$result
,
0
,
-
1
,
self
::
$fetchModeMap
[
$this
->
defaultFetchMode
]
|
OCI_RETURN_NULLS
|
$fetchStructure
|
OCI_RETURN_LOBS
);
return
$result
;
}
}
lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
View file @
149899ea
...
...
@@ -370,7 +370,9 @@ class OCI8Statement implements IteratorAggregate, Statement
*/
public
function
getIterator
()
{
return
new
OCI8Iterator
(
$this
->
_sth
,
$this
->
_defaultFetchMode
);
while
(
$row
=
$this
->
fetch
())
{
yield
$row
;
}
}
/**
...
...
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereIterator.php
deleted
100644 → 0
View file @
048cb6ef
<?php
namespace
Doctrine\DBAL\Driver\SQLAnywhere
;
use
Doctrine\DBAL\Driver\AbstractIterator
;
class
SQLAnywhereIterator
extends
AbstractIterator
implements
\Iterator
{
protected
function
fetch
()
{
$result
=
sasql_stmt_result_metadata
(
$this
->
cursor
);
switch
(
$this
->
defaultFetchMode
)
{
case
\PDO
::
FETCH_ASSOC
:
return
sasql_fetch_assoc
(
$this
->
cursor
);
case
\PDO
::
FETCH_BOTH
:
return
sasql_fetch_array
(
$result
,
SASQL_BOTH
);
case
\PDO
::
FETCH_CLASS
:
return
sasql_fetch_object
(
$result
);
case
\PDO
::
FETCH_NUM
:
return
sasql_fetch_row
(
$result
);
case
\PDO
::
FETCH_OBJ
:
return
sasql_fetch_object
(
$result
);
default
:
throw
new
SQLAnywhereException
(
'Fetch mode is not supported: '
.
$this
->
defaultFetchMode
);
}
}
}
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php
View file @
149899ea
...
...
@@ -278,7 +278,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
public
function
getIterator
()
{
return
new
SQLAnywhereIterator
(
$this
->
stmt
,
$this
->
defaultFetchMode
);
while
(
$row
=
$this
->
fetch
())
{
yield
$row
;
}
}
/**
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvIterator.php
deleted
100644 → 0
View file @
048cb6ef
<?php
namespace
Doctrine\DBAL\Driver\SQLSrv
;
use
Doctrine\DBAL\Driver\AbstractIterator
;
class
SQLSrvIterator
extends
AbstractIterator
implements
\Iterator
{
protected
function
fetch
()
{
return
sqlsrv_fetch_array
(
$this
->
cursor
,
$this
->
defaultFetchMode
);
}
}
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
View file @
149899ea
...
...
@@ -295,7 +295,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*/
public
function
getIterator
()
{
return
new
SQLSrvIterator
(
$this
->
stmt
,
$this
->
defaultFetchMode
);
while
(
$row
=
$this
->
fetch
())
{
yield
$row
;
}
}
/**
...
...
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