해보자

[PHP] insert multiple(transaction) 본문

PHP

[PHP] insert multiple(transaction)

안댕 2020. 9. 29. 01:19
$mysqli->begin_transaction();
$insert1 = $mysqli->query(" <<< INSERT Query1 >>> ");
$insert2 = $mysqli->query(" <<< INSERT Query2 >>> ");

if($insert1 && $insert2) {
    $mysqli->commit();
} else {
    $mysqli->rollback();
}



Reference

https://stackoverflow.com/questions/25263500/how-to-insert-into-two-tables-using-php-with-transaction/25263624