i have a problem with transaction, because if I try to enter a wrong query, the system should not enter either.
Instead the system inserts the first query, and the second is not, and does not enter the Rollback
This is my code:
$conn = connect();
try {
/* set autocommit to off */
$conn->autocommit(FALSE);
/* MY QUERY */
$conn->query("INSERT INTO `transazioni` (`id`, `nome`, `numero`) VALUES (NULL, 'luca', '12')");
$conn->query("I--NSERT INTO `transazioni` (`id`, `nome`, `numero`) VALUES (NULL, 'paolo', '12')");
/* commit transaction */
$conn->commit();
} catch (Exception $e) {
// faccio rollback
$conn->rollback();
echo "enter in rollback";
}
How can i fix it ?
Thanks Andrea