123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- function RunFile($file){
-
- }
- $settings=parse_ini_file("settings.ini",true);
- $host=$settings["database"]["host"];
- $db=$settings["database"][ "database"];
- $username=$settings["database"][ "username"];
- $password=$settings["database"][ "password"];
- $PDO=new PDO("mysql:host=$host;dbname=$db",$username,$password);
- $version=0;
- if (file_exists("db_version_info"))
- $version=intval(file_get_contents("db_version_info"));
- $scriptsToRun=array();
- $items=glob("DB Scripts/*.sql");
- $scriptsToRun[0]=$items;
- $items=glob("DB Scripts/*");
- foreach ($items as $i){
- if (!is_dir($i))
- continue;
-
- $moreItems=glob($i.'/*');
- if (count($moreItems)>0)
- $scriptsToRun[intval(pathinfo($i)['basename'])]=$moreItems;
- }
- $total=count($scriptsToRun);
- $dbVersion=0;
- for ($v=$version;$v<$total;$v++){
- foreach ($scriptsToRun[$v] as $s){
- echo "Running $s";
- $PDO->query(file_get_contents($s));
- var_dump($PDO->errorInfo());
- }
- }
- file_put_contents("db_version_info", $total);
|