Last active
April 1, 2020 20:14
-
-
Save duzun/678b98fde844c030c77a2668e3edb819 to your computer and use it in GitHub Desktop.
Run Multi Query using mysqli in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($mysqli->multi_query("START TRANSACTION;$query--\nCOMMIT;")) { | |
$idx = 0; | |
$ret = 0; | |
if($output = $mysqli->error) { | |
echo $output, PHP_EOL; | |
die(-4); | |
} | |
else { | |
do { | |
echo ++$idx; | |
if($rs = $mysqli->use_result()) { $rs->free(); } | |
// elseif($output = $mysqli->error) { $ret = -7; break; } | |
if(!$mysqli->more_results()) break; | |
if(!$mysqli->next_result()) break; | |
echo '.'; | |
} | |
while(true); | |
if($ret != 0 or $output = $mysqli->error and $ret = -4) { | |
echo $output, PHP_EOL; | |
die($ret); | |
} | |
else { | |
echo " done", PHP_EOL; | |
} | |
} | |
} | |
else { | |
$output = $mysqli->error; | |
echo $output, PHP_EOL; | |
die(-3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment