hi!
i am trying to make a script that updates some tables in my database and what i want to do is to commit the changes if the statements success or rollback if any of the statements fail.
i search on the internet how to do it but all i was able to found is the mysqli method. but in my scripts i don't use the mysqli methot because a lot of people says that it is old and obsolete, so i use the PDO wich is better (or not?)
is it a way to use COMMIT and ROLLBACK with the PDO object? thx
here is my code.




try
{
$connection = new PDO('mysql:host=localhost;dbname=uvm', 'abcd', 'xxxx');
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connection->exec('SET NAMES "utf8"');
}

catch (PDOException $e)
{
echo "Error";
exit();
}



try
{
$sql = "UPDATE users SET Last_Login = CURDATE() WHERE Id = :Id";
$s = $connection->prepare($sql);
$s->bindValue(':Id', $_SESSION['Currentuserid']);
$s->execute();
}
catch (PDOException $e)
{
echo "Error";
exit();
}


try
{
$sql = "UPDATE account SET Credits = 5000 WHERE Id = :Id";
$s = $connection->prepare($sql);
$s->bindValue(':Id', $_SESSION['Currentuserid']);
$s->execute();
}
catch (PDOException $e)
{
echo "Error";
exit();
}