Skip to content

Instantly share code, notes, and snippets.

@tborychowski
Created October 11, 2012 14:13
Show Gist options
  • Save tborychowski/3872588 to your computer and use it in GitHub Desktop.
Save tborychowski/3872588 to your computer and use it in GitHub Desktop.
PHP :: Import SQL file to DB
// import sql file
$file_content = file('updates.sql');
$query = "";
foreach($file_content as $sql_line){
if(trim($sql_line) != "" && strpos($sql_line, "--") === false){
$query .= $sql_line;
if (substr(rtrim($query), -1) == ';'){
$result = $dbo->dbEdit($query);
echo $query.'<br>Result: '.($result==1?'OK':$result).'<br><br><br>';
$query = "";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment