i'm trying issue following in mysql via node.js (using https://github.com/mysqljs/mysql library).
i'm using transaction api rollback when error happens doesn't appear roll back. next tried simplify problem , put directly in phpmyadmin sql box following....
start transaction; update users set balance=balance + 1 id_user='someuserid' rollback work;
i expecting user balance remain @ it's previous value (124) instead keeps adding 1 , shows updated balance of 125 @ end of this.
any idea i'm doing wrong? mysql db isn't supporting of transactions and/or update allowed rolled in transactions?
ok, problem solved.
for reference else encountering because of table engine being used.
my table using myisasm not support transactions , fails silently. autocommits on every transaction hence rollback never did anything.
the fix change table engine myisam innodb (did via phpmyadmin via alter table table_name engine=innodb;
sql command.
now following works perfectly.
start transaction; update users set balance = 8 id_user='s10'; update users set balance = 9 id_user='s12'; rollback;
Comments
Post a Comment