php - mysql insert rows in multiple tables -
i have database multiple tables, in al tables there have row because else query going wrong. in 1 of insert pages insert al rows seperatly in tables. there more efficient , safe way this? maybe in mysql (cascade)?
afaik there no other way same data different tables in same statement. can try using transactions.
start transaction; insert t1 (field1, field2) values ('data1','data2');
after inserting data can check them if ok , if expected commit queries:
commit;
or rollback, removes changes sience "start transaction".
rollback;
Comments
Post a Comment