PHP + MySQL transactions examples

后端 未结 9 2328
一整个雨季
一整个雨季 2020-11-21 11:50

I really haven\'t found normal example of PHP file where MySQL transactions are being used. Can you show me simple example of that?

And one more question. I\'ve alr

9条回答
  •  借酒劲吻你
    2020-11-21 12:17

    I think I have figured it out, is it right?:

    mysql_query("START TRANSACTION");
    
    $a1 = mysql_query("INSERT INTO rarara (l_id) VALUES('1')");
    $a2 = mysql_query("INSERT INTO rarara (l_id) VALUES('2')");
    
    if ($a1 and $a2) {
        mysql_query("COMMIT");
    } else {        
        mysql_query("ROLLBACK");
    }
    

提交回复
热议问题