I have a .sql
file that contains a handful of TRUNCATE
, DROP TABLE IF EXISTS
and CREATE TABLE
statements as well as thousands of INSERT
and UPDATE
statements.
I'm trying to use PHP to execute all the statements in the file in batch as follows:
$sql = file_get_contents('path/to/sql/file.sql');
$link->($sql);
Where $link
is a valid MySQLi DB link. I've also tried swapping out $link->($sql)
with $link->multi_query($sql)
, but neither seem to work.
If it makes any difference, I'm attempting to do this in an XAMPP localhost environment on Windows 10 with PHP 7.1 and MariaDB 15.1.
Does anyone know why this would cause problems and not work?
What's the best way in PHP to execute a SQL file with thousands of statements in it?
Thanks.