Tuesday, August 27, 2019

mysqli - Execute multiple MySQL statement at once in PHP?

Currently, my code works if it has only one statement:



$stm = $conn->prepare("insert into my_table(a, b) values(?, ?)");

$stm->bind_param("ii", $a, $b);


Now I want to execute multiple statements at once to avoid round-trips.



$stm = $conn->prepare("delete my_table where a = ?; 
insert into my_table(a, b) values(?, ?)");
$stm->bind_param("iii", $a, $a, $b);



The code above doesn't work though.

No comments:

Post a Comment