Answer the question
In order to leave comments, you need to log in
Reduce the number of queries in the database?
Basically, I have this code:
function insertGameMysql() {
global $arrGame;
global $link;
for ($i = 1; $i < count($arrGame)+1; $i++) {
$query = "('".$i."','".trim($arrGame[$i][0])."','".$arrGame[$i][1]."','".$arrGame[$i][2]."','".$arrGame[$i][3]."','".$arrGame[$i][4]."','".$arrGame[$i][5]."','".$arrGame[$i][6]."','".$arrGame[$i][7]."')";
$stmt = $link->query('INSERT INTO `games` VALUES '.$query);
}
exit();
}
Answer the question
In order to leave comments, you need to log in
INSERT INTO games (one, two, three) VALUES (1, 2, 3), (4, 5, 6), (7, 8, 9);
https://dev.mysql.com/doc/refman/5.7/en/insert.html
You can get by with one insert
And in the above code, the vulnerability is SQL Injection - read about the use of prepared queries.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question