I need to import all the old data for backup but i have too many data that it cant execute all query like 2k of query in my .sql file. Some are executed but not 100% of all the query are executed. There are no errors showed after. I tried to loop it four times maybe it will execute it all because when i tried with no loop it only creates 4 tables but in the backup I have 9 tables so i clicked the button again and it turned out to be 8 tables on the database and on my 3rd try clicking it again it has now 9 tables but the data is incomplete.
Here is a test i made for backup and recovery
here is my code:
<?php 
ini_set('max_execution_time', 300);
for($c = 0; $c < 4;$c++){
    $connection = mysqli_connect('localhost','root','','test');
    $filename = 'backup.sql';
    $handle = fopen($filename, "r+");
    $contents = fread($handle, filesize($filename));
    $sql = explode(';', $contents);
    foreach ($sql as $query) {
        $result = mysqli_query($connection,$query);
    }
    fclose($handle);
}
echo "Successfully Imported";
?>
 
    