Answers for "php database transactions how often to use"

PHP
1

pdo transaction

<?php
/* Begin a transaction, turning off autocommit */
$dbh->beginTransaction();

try	{
	/* Change the database schema and data */
    $sth = $dbh->exec("DROP TABLE fruit");
    $sth = $dbh->exec("UPDATE dessert
        SET name = 'hamburger'");
}
catch(Exception $e){
  /* Recognize mistake and roll back changes */
  $dbh->rollBack();
}
/* Commit changes */
$dbh->commit();
Posted by: Guest on September-03-2020

Code answers related to "php database transactions how often to use"

Browse Popular Code Answers by Language