PHP - Execute mysql .sql dump files via php mysqli

The following script allows you to execute an sql dump file (for instance produced with mysqldump or phpmyadmin).

$mysqli = new mysqli('localhost', 'username', 'password', 'databasename');
if (mysqli_connect_error()) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
echo 'Success... ' . $mysqli->host_info . "<br />";
echo 'Retrieving dumpfile' . "<br />";
$sql = file_get_contents('../dump/caldata.sql');
if (!$sql){
	die ('Error opening file');
echo 'processing file <br />';
echo 'done.';
I dont know how old this post is, but just a warning about mysqli_multi_query..

Mysqli_multi_query doesnt seem to handle Alter table queries correctly. It breaks when trying to set innodb constraints with alter table.
Setting delimiters for events also seems to cause problems.
rendered @ Wed Apr 23 22:58:21 CEST 2014