Db/transaction?

Does anyone know where to find a good example about the implementation of transactions over db?
In the old(zend) documentation something was written but on laminas docs I haven’t found it.

On stackoverflow there is a post: Database transactions in Zend Framework: Are they isolated?

On codingexplained: Using Transactions with Zend\Db in Zend Framework 2

but the two explanations seem a little different.
The first one use specifically the select:

$db->select()->forUpdate() ...

The second seems more general:

$connection->beginTransaction();
/* do queries or other things */
$connection->commit();

Are both correct?
Thank you

Welcome to the forums! :smiley:

No because in the current version of laminas-db there is no method forUpdate.
The second example should work.

1 Like