Skip to content

Commit bdd4181

Browse files
authored
Merge pull request #11183 from nextcloud/feat/devmanual/database-result-fetch
feat(devmanual): Add \OCP\DB\IResult::fetch deprecation
2 parents 8cb3a5d + 3e7430f commit bdd4181

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ Changed APIs
176176
Deprecated APIs
177177
^^^^^^^^^^^^^^^
178178

179+
* ``\OCP\DB\IResult::fetch``: use the new ``fetchAssociative``, ``fetchNumeric`` and ``fetchOne`` instead. If you called ``fetch`` without arguments, ``fetchAssociative`` is the direct replacement. Beware that the new methods throw a different exception.
180+
* ``\OCP\DB\IResult::fetchAll``: use the new ``fetchAllAssociative``, ``fetchAllNumeric`` and ``fetchOne`` instead. If you called ``fetchAll`` without arguments, ``fetchAllAssociative`` is the direct replacement. Beware that the new methods throw a different exception.
179181
* ``\OCP\Preview\BeforePreviewFetchedEvent`` passing ``null`` for ``width, height, crop or mode`` is deprecated. Starting with Nextcloud 31 they are mandatory.
180182

181183
Removed APIs

developer_manual/basics/storage/database.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Inside your database layer class you can now start running queries like:
3535
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
3636
);
3737
38-
$cursor = $qb->execute();
39-
$row = $cursor->fetch();
40-
$cursor->closeCursor();
38+
$result = $qb->executeQuery();
39+
$row = $result->fetchAssociative();
40+
$result->closeCursor();
4141
4242
return $row;
4343
}
@@ -183,9 +183,9 @@ To create a mapper, inherit from the mapper base class and call the parent const
183183
$qb->expr()->eq('name', $qb->createNamedParameter($name, IQueryBuilder::PARAM_STR))
184184
);
185185
186-
$cursor = $qb->execute();
187-
$row = $cursor->fetch();
188-
$cursor->closeCursor();
186+
$result = $qb->executeQuery();
187+
$row = $result->fetchAssociative();
188+
$result->closeCursor();
189189
190190
return $row['count'];
191191
}

0 commit comments

Comments
 (0)