Tuesday 27 August 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...