Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysqli rollback is not working

I have a MySQL db and I am using mysqli.

for some reason I can't get transactions to work properly. If I call $mysqli->rollback(), it does not roll back.

example code:

$mysqli->autocommit(false);

$sql = "INSERT INTO myTable (name , color) VALUES ('Dan' , 'red')";

$mysqli->query($sql);

$mysqli->rollback();

Tthe result is that another row is added to myTable. Can anyone think of a reason why?

like image 964
dors Avatar asked Nov 24 '25 10:11

dors


1 Answers

are you using myIsam or innodb?? becouse it only works for innodb as far as i know

like image 71
derki Avatar answered Nov 26 '25 01:11

derki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!