From 3e7430fb2660cd5fee3aeff01fa560343d9c99df Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 5 Oct 2023 13:39:43 +0200 Subject: [PATCH] feat(devmanual): Add \OCP\DB\IResult::fetch deprecation Signed-off-by: Christoph Wurst --- .../app_upgrade_guide/upgrade_to_28.rst | 2 ++ developer_manual/basics/storage/database.rst | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst b/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst index 2f9e11bbe77..ccfeb7527d8 100644 --- a/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst +++ b/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.rst @@ -176,6 +176,8 @@ Changed APIs Deprecated APIs ^^^^^^^^^^^^^^^ +* ``\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. +* ``\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. * ``\OCP\Preview\BeforePreviewFetchedEvent`` passing ``null`` for ``width, height, crop or mode`` is deprecated. Starting with Nextcloud 31 they are mandatory. Removed APIs diff --git a/developer_manual/basics/storage/database.rst b/developer_manual/basics/storage/database.rst index baa7a7bfc82..dd71e9a1ab5 100644 --- a/developer_manual/basics/storage/database.rst +++ b/developer_manual/basics/storage/database.rst @@ -35,9 +35,9 @@ Inside your database layer class you can now start running queries like: $qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)) ); - $cursor = $qb->execute(); - $row = $cursor->fetch(); - $cursor->closeCursor(); + $result = $qb->executeQuery(); + $row = $result->fetchAssociative(); + $result->closeCursor(); return $row; } @@ -183,9 +183,9 @@ To create a mapper, inherit from the mapper base class and call the parent const $qb->expr()->eq('name', $qb->createNamedParameter($name, IQueryBuilder::PARAM_STR)) ); - $cursor = $qb->execute(); - $row = $cursor->fetch(); - $cursor->closeCursor(); + $result = $qb->executeQuery(); + $row = $result->fetchAssociative(); + $result->closeCursor(); return $row['count']; }