Skip to content

Instantly share code, notes, and snippets.

@davidsword
Created September 14, 2016 21:38
Show Gist options
  • Save davidsword/6a76063554bc1b0c7242242ab75c283f to your computer and use it in GitHub Desktop.
Save davidsword/6a76063554bc1b0c7242242ab75c283f to your computer and use it in GitHub Desktop.
<?
$mysqli = new mysqli('localhost', 'user', 'password', 'database');
$handle = fopen('filename.sql', 'rb');
if ($handle) {
while (!feof($handle)) {
// This assumes you don't have a row that is > 1MB (5000000)
// which is unlikely given the size of your DB
// Note that it has a DIRECT effect on your scripts memory
$buffer = stream_get_line($handle, 5000000, ";\n");
$mysqli->query($buffer);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment