Created
August 10, 2010 00:40
-
-
Save Theaxiom/516394 to your computer and use it in GitHub Desktop.
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
<?php | |
require_once('../config/database.php'); | |
$DbConfig = new DATABASE_CONFIG(); | |
$username = $DbConfig->default['login']; | |
$password = $DbConfig->default['password']; | |
$hostname = $DbConfig->default['host']; | |
$dbname = $DbConfig->default['database']; | |
$filename = "../config/sql/kinspire_mysql.sql"; | |
//connection to the database | |
$db = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); | |
mysql_select_db($dbname); | |
$msg = false; | |
$sql = false; | |
if ($f = fopen($filename, 'r')) do { | |
$line = fgets($f); | |
$line = trim($line); | |
if(!@ereg('^--', $line)) | |
{ | |
$sql .= " " . $line; | |
} | |
} while (!feof($f)); | |
fclose($f); | |
if(!$sql) { | |
$msg = "No queries found in $filename"; | |
return false; | |
} | |
$queries = explode(';', $sql); | |
foreach($queries as $query) { | |
$query = trim($query); | |
if($query == "") { | |
continue; | |
} | |
if(!mysql_query($query . ';')) { | |
$msg = "query " . $query . " failed"; | |
return false; | |
} | |
} | |
if ($msg === false) { | |
$msg = "Done"; | |
} | |
echo $msg; | |
mysql_close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment