PHP Classes

Correct utilization of Transactions

Recommend this page to a friend!

      PDO Multi Connection Class  >  All threads  >  Correct utilization of Transactions  >  (Un) Subscribe thread alerts  
Subject:Correct utilization of Transactions
Summary:The correct way to utilize the transactions with the class
Messages:1
Author:Marco Rossi
Date:2013-01-17 12:34:27
 

  1. Correct utilization of Transactions   Reply   Report abuse  
Picture of Marco Rossi Marco Rossi - 2013-01-17 12:34:27
Hi!
It's correct utilize the transactions in this way?


try
{

$db_pdo->transaction("B");
$db_pdo->delete("test_insert");
$db_pdo->transaction("C"); //Commit and apply changes

}catch(PDOException $e) {

$db_pdo->transaction("R");

}


And make SELECT in this way?

$db_pdo->transaction("B");
$stmt = $db_pdo->query("SELECT * FROM test_insert;");
$db_pdo->transaction("C"); //Commit and apply changes
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrValues = $stmt->fetchAll();


Thank you very much!!
Byezz