Skip to content

Commit f7c1aea

Browse files
committed
feat: Mark IQueryBuilder::execute as removed
Signed-off-by: Carl Schwan <[email protected]>
1 parent 1ee53e4 commit f7c1aea

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_33.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,33 @@ Removed APIs
124124
deprecated since Nextcloud 20 and were now removed. Instead use ``\OCP\Search\SearchResult`` and
125125
``\OCP\Search\IProvider``, available since Nextcloud 20.
126126
- The ``\OC_Util::runningOnMac()`` method was removed. Instead you can just check ``PHP_OS_FAMILY === 'Darwin'``.
127+
- The ``\OCP\DB\IQueryBuilder::execute`` method was deprecated since Nextcloud 22 and was now removed.
128+
Instead use the ``\OCP\DB\IQueryBuilder::executeQuery`` when doing executing a ``SELECT`` query and ``\OCP\DB\IQueryBuilder::executeStatement``
129+
method when executing a ``UPDATE``, ``INSERT`` and ``DELETE`` statement, available since Nextcloud 20.
130+
131+
Instead of catching a exceptions from the Doctrine DBAL package, you now need to catch ``OCP\DB\Exception``
132+
and check the `getReason``. For example, the following old code:
133+
134+
.. code-block:: php
135+
136+
try {
137+
$qb->insert(...);
138+
$qb->execute();
139+
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException) {
140+
// Do stuff
141+
}
142+
143+
Should be replaced by the following code:
144+
145+
.. code-block:: php
146+
147+
try {
148+
$qb->insert(...);
149+
$qb->executeStatement();
150+
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException) {
151+
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
152+
throw $e;
153+
}
154+
155+
// Do stuff
156+
}

0 commit comments

Comments
 (0)