PHP code example of lozitskiys / pdo-nested-transactions

1. Go to this page and download the library: Download lozitskiys/pdo-nested-transactions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lozitskiys / pdo-nested-transactions example snippets



$db = new PdoWithNT(/*credentials here*/);

try {
    $db->beginTransaction();

    // some logic here

    try {
        $db->beginTransaction();

        // some logic here

        $db->commit();
    } catch (Exception $e) {
        $db->rollBack();
        throw $e;
    }

    $db->commit();
} catch (Exception $e) {
    $db->rollBack();
    throw $e;
}