Skip to content

Commit 23702d0

Browse files
authored
Merge pull request #13866 from nextcloud/carl/fetch-33
feat(nc-upgrade-33): Add notes related to IResult::fetch/fetchAll
2 parents 3fc151d + 0362f3c commit 23702d0

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_33.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ Added Events
8888
Added APIs
8989
^^^^^^^^^^
9090

91-
- TBD
91+
- We now expose ``\OCP\DB\IResult::iterateAssociative``, ``\OCP\DB\IResult::iterateNumeric`` from doctrine/dbal.
92+
These two methods returns iterators that can be directly used in a `foreach` to iterate over a SQL query result.
93+
For example:
94+
95+
.. code-block:: php
96+
97+
$result = $qb->executeQuery();
98+
foreach ($result->iterateAssociative() as $row) {
99+
$id = $row['id'];
100+
}
101+
$result->closeCursor();
92102
93103
Changed APIs
94104
^^^^^^^^^^^^
@@ -98,7 +108,12 @@ Changed APIs
98108
Deprecated APIs
99109
^^^^^^^^^^^^^^^
100110

101-
- TBD
111+
- The ``\OCP\DB\IResult::fetch`` and ``\OCP\DB\IResult::fetchAll`` are soft-deprecated. Instead you can use
112+
``\OCP\DB\IResult::fetchAssociative``, ``\OCP\DB\IResult::fetchNumeric`` and ``\OCP\DB\IResult::fetchOne``
113+
as replacement for ``\OCP\DB\IResult::fetch``; and ``\OCP\DB\IResult::fetchAllAssociative``,
114+
``\OCP\DB\IResult::fetchAllNumeric`` and ``\OCP\DB\IResult::fetchFirstColumn`` as replacement for
115+
``\OCP\DB\IResult::fetchAll``. If you use rector, you can use the Nextcloud33 set, to automatically port
116+
most of your code to the new methods.
102117

103118
Removed APIs
104119
^^^^^^^^^^^^

0 commit comments

Comments
 (0)