private function importDB($config) { $rs = importSQL(ROOT_PATH . "/common/apps/install/data/install.sql"); if (true !== $rs) { $this->error($rs[0]); return; } }
public function insert() { //下载升级包 if ($_POST["doDownload"] && $_POST["version"]) { } //执行升级,需要zip模块支持 if ($_POST["doUpdate"] && $_POST["version"]) { $version = $this->getVersion($_POST["version"]); $zip = new ZipArchive(); $tmpFolder = $this->local . "update_" . $_POST["version"]; $rs = $zip->open($this->getLocalPath($version["file"])); if ($rs === true) { if (!is_dir($tmpFolder)) { $rs = mkdir($tmpFolder, 0777); } $zip->extractTo($tmpFolder); } $zip->close(); unlink($this->getLocalPath($version["file"])); //暂定根目录为ENTRY_PATH上级目录 //更新数据库 $sqlFile = $tmpFolder . "/upgrade.sql"; if (file_exists_case($sqlFile)) { $rs = importSQL($sqlFile); unlink($sqlFile); if (true !== $rs) { $this->error($rs[0]); return; } } //复制文件 recursionCopy($tmpFolder, dirname(ENTRY_PATH)); //删除更新文件 delDirAndFile($tmpFolder); //更新系统版本 $model = D("Config"); $model->where(array("alias" => 'system.version'))->save(array("value" => $version["version"])); } }
// plik z zrzutem bazy danych z SQL $nazwa_bazy = "projektsklep"; // nazwa bazy danych // ustanawiamy połączenie z bazą, jak się nie łączy, wyświetlamy błąd $connection = @mysql_connect($adres, $uzytkownik, $haslo); // tworzymy baze mysql_query("drop database if exists {$nazwa_bazy}"); mysql_query("CREATE DATABASE {$nazwa_bazy}"); // wybieramy baze $db = @mysql_select_db($nazwa_bazy, $connection); mysql_query("SET NAMES utf8"); // otwieramy plik z skryptem SQL i dodajemy go do bazy function importSQL($sqlFileHandle) { $query = ''; while (!feof($sqlFileHandle)) { $row = trim(fgets($sqlFileHandle)); if (substr($row, 0, 1) == '#' or empty($row)) { continue; } $query .= $row; if (substr($row, -1, 1) == ';') { mysql_query($query); $query = ''; } } } $handle = fopen($plik, 'r'); importSQL($handle); // wszystko sie udalo, przekierowanie na stronę z info header("Location: baza_nie_dziala.php?stworzono=tak");
public function appUpgrade() { $upgradeSql = sprintf("%s/apps/%s/data/sqls/upgrade.sql", ROOT_PATH, $this->appConfig["alias"]); if (is_file($upgradeSql)) { $rs = importSQL($upgradeSql); if (true !== $rs) { $this->error = $rs[0]; return false; } } return true; }
$splitter = array_map(create_function('$line', 'return preg_replace("/[\\s;]*$/", "", $line);'), $splitter); # remove empty lines return array_filter($splitter, create_function('$line', 'return !empty($line);')); } ?> <div id="progress_message" class="message"> <div id="progress" class="message"></div><div id="information" class="message"></div> </div> <?php // Temporary variable, used to store current query $templine = ''; if ($_GET['db_type'][0] == 'production') { $filename = HOME_DIR . DS . 'engine' . DS . 'install' . DS . 'inoerp_prod.sql'; } else { $filename = HOME_DIR . DS . 'engine' . DS . 'install' . DS . 'inoerp.sql'; } try { importSQL($filename, $dbc); // Tell user that the process is completed echo '<script language="javascript">document.getElementById("information").innerHTML="Process completed"</script>'; echo '<ul class="list-unstyled">'; echo "<li>All tables have been Successfully imported</li>"; echo "<li>Verify that the file install.php is removed from home directory. If not, delete it.</li>"; echo "<li><a href='" . HOME_URL . "'>Go to the home page </a> & Login to the system with default user name/password :inoerp/inoerp and reset the password.</li>"; echo '</ul>'; unlink('install.php'); } catch (Exception $e) { echo "<br>Tables import fialed" . $e->getMessage(); } ?>