I want to execute two queries at once using mysqli_multi_query statement but only the first query is getting executed. Here is my code
<?php
$connection=mysqli_connect("localhost","root","","entries");
$query1="select * from jobs";
$query1exe=mysqli_query($connection,$query1);
while($query1collector=mysqli_fetch_array($query1exe,MYSQLI_ASSOC)) {
$query2="select sleep(10);
select 1;";
mysqli_multi_query($connection,$query2);
}
?>
In the above code there is a delay of 10 seconds. But when I interchange the two select statements as below there is no delay at all which made me conclude that the second query is not getting executed.
<?php
$connection=mysqli_connect("localhost","root","","entries");
$query1="select * from jobs";
$query1exe=mysqli_query($connection,$query1);
while($query1collector=mysqli_fetch_array($query1exe,MYSQLI_ASSOC)) {
$query2="select 1;
select sleep(10);";
mysqli_multi_query($connection,$query2);
}
?>
What is happening? I am using php 5.5.11. I am new to mysqli statements.