I'm inserting a button that will perform a series of queries on the database (MySQL). I would like to know if I can use transaction control as the example or if there is another way to use it:
try {
$db->beginTransaction();
$db->query('query 1');
$db->query('query 2');
$db->query('query 3');
$db->commit();
} catch (Exception $e) {
$db->rollback();
}