In short .... Use multiple updates in a single variable
Type: $ query = 'update .....; update ......... '
Is there anyway?
In short .... Use multiple updates in a single variable
Type: $ query = 'update .....; update ......... '
Is there anyway?
You should be using mysql_query
, but only accept one query. Try using mysqli :: multi_query . An example;
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* verifica conexão */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
/* executa a sua multi query */
if ($mysqli->multi_query($query)) {
do {
/* Faz print separado do resultado de cada query */
if ($result = $mysqli->store_result()) {
while ($row = $result->fetch_row()) {
printf("%s\n", $row[0]);
}
$result->free();
}
/* separa cada resultado por traços */
if ($mysqli->more_results()) {
printf("-----------------\n");
}
} while ($mysqli->next_result());
}
/* fecha conexão */
$mysqli->close();
?>