0
Summarizing.... Use multiple updates in one variable
Type: $query = 'update..... ; update.........'
Is there any way?
0
Summarizing.... Use multiple updates in one variable
Type: $query = 'update..... ; update.........'
Is there any way?
2
You must be using the mysql_query
, but accepts only 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();
?>
Browser other questions tagged php mysql
You are not signed in. Login or sign up in order to post.
I think you better try to better formulate your question, at least me I don’t understand what you’re trying to do,
– MarceloBoni
I understood your question (it was not easy) but to formulate the answer, I would have to know which driver you use: mysqli? PDO?
– Rafael Mena Barreto
Excuse me..... I use mysqli
– Naldson
Wouldn’t be of different lines?
– MarceloBoni
What the
sgbd
using?– MarceloBoni
This might help: http://stackoverflow.com/questions/6821184/how-do-you-do-multiple-sql-statments-in-one-mysql-query
– Filipe Moraes