Hi , I have two database with MyIsam Engine : db1 : usersys1 db2 : usersys2 when user register on my site i will Insert all user info to both db separately in last register step. how it possible to be sure we will don't miss one of this Inserts ? (for example db1 ok , db2 insert failure due to anything) I need to insert all data to both database %100. for example maybe one of databases have problem or user connection closed before full insert.
$query = 'MYSQL_QUERY'; $first_data = mysql_query($query, data1); if($first_data){ $second_data = mysql_query($query, data2); if($second_data){ echo 'inserted both';}else{ echo 'unable to insert to second one';} } else { echo 'unable to insert to both databases.'; } PHP: Peace,
maybe db2 result is failure , can we use rollback or such things for db1 ? can we use commit in mysql 5 for MyIsam engine? if yes , how to use?
I googled mysql php transactions and came up with this: http://www.devarticles.com/c/a/MySQL/Using-Transactions-with-MySQL-4.0-and-PHP/ You can easily adapt the last PHP script on that page to use 2 mysql connections. If, at some point one of the queries fails (either databases), call the rollback function created there (for both dbs).