I am importing a mysqlsqldump
as follows.
$command = file_get_contents($dumpfile);
$conn->multi_query($command);
while (mysqli_next_result($conn)); // Flush out the results.
I have stripped down the code here, to just focus on the problem.
Now everything is working correctly, except that I have a query after this command.
And that query is not finding the tables which are supposed to be there after the import from previous step.
Then I realised that the import process using above method somehow seems asyncronous, and long after the php has finished execution the import seems to be going on. And once the import has finished, I am able to execute that same query manually which earlier returned the error saying "so and so table.column
doesn't exist".
So, Is there a way to wait it out, for the multi_query
process to complete, and then proceed with the execution in php?
Ok, My bad, actually, the following line does make the php wait till the processing is completed, its just that I had passed a different connection handle.
while (mysqli_next_result($conn)); // Flush out the results.