Created
October 11, 2012 14:13
-
-
Save tborychowski/3872588 to your computer and use it in GitHub Desktop.
PHP :: Import SQL file to DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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