Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run Multi Query using mysqli in PHP
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