# Db/transaction?

**URL:** <https://discourse.laminas.dev/t/db-transaction/1656>\
**Category:** Components & MVC\
**Tags:** zend-db, laminas-db\
**Created:** [June 1, 2020, 6:12pm UTC](https://discourse.laminas.dev/t/db-transaction/1656 "2020-06-01T18:12:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claudio\_Eterno](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/claudio_eterno/32/675_2.png) [@Claudio\_Eterno](https://discourse.laminas.dev/u/Claudio_Eterno)\
**Post date:** [June 1, 2020, 6:12pm UTC](https://discourse.laminas.dev/t/db-transaction/1656/1 "2020-06-01T18:12:56Z")

</div>

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?](https://stackoverflow.com/questions/7618300/database-transactions-in-zend-framework-are-they-isolated/7618431#7618431)

On codingexplained: [Using Transactions with Zend\Db in Zend Framework 2](https://codingexplained.com/coding/php/zend-framework/using-transactions-with-zend-db-in-zend-framework-2)

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

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

```

The second seems more general:

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

```

Are both correct?  
Thank you

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [June 1, 2020, 7:11pm UTC](https://discourse.laminas.dev/t/db-transaction/1656/2 "2020-06-01T19:11:47Z")

</div>

Welcome to the forums! 😃

> [@Claudio\_Eterno](#):
>
> Are both correct?

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