php代碼:備份、恢複sql資料庫_PHP教程

來源:互聯網
上載者:User
php(做為現在的主流開發語言)代碼:備份、恢複sql資料庫

require(includes/application_top.php(做為現在的主流開發語言));

if ($HTTP_GET_VARS[action]) {
switch ($HTTP_GET_VARS[action]) {
case forget:
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = DB_LAST_RESTORE");
$messageStack->add_session(SUCCESS_LAST_RESTORE_CLEARED, success);
tep_redirect(tep_href_link(FILENAME_BACKUP));
break;
case backupnow:
tep_set_time_limit(0);
$schema = # citespa, Open Source E-Commerce Solutions . "" .
# http://www.XXXXXX.com . "" .
# . "" .
# Database Backup For . STORE_NAME . "" .
# Copyright (c) . date(Y) . . STORE_OWNER . "" .
# . "" .
# Database: . DB_DATABASE . "" .
# Database Server: . DB_SERVER . "" .
# . "" .
# Backup Date: . date(php(做為現在的主流開發語言)_DATE_TIME_FORMAT) . "";
$tables_query = tep_db_query(show tables);
while ($tables = tep_db_fetch_array($tables_query)) {
list(,$table) = each($tables);
$schema .= drop table if exists . $table . ; . "" .
create table . $table . ( . "";
$table_list = array();
$fields_query = tep_db_query("show fields from " . $table);
while ($fields = tep_db_fetch_array($fields_query)) {
$table_list[] = $fields[Field];
$schema .= . $fields[Field] . . $fields[Type];
if (strlen($fields[Default]) > 0) $schema .= default . $fields[Default] . ;
if ($fields[Null] != YES) $schema .= not null;
if (isset($fields[Extra])) $schema .= . $fields[Extra];
$schema .= , . "";
}
$schema = ereg_replace(",$", , $schema);

// Add the keys
$index = array();
$keys_query = tep_db_query("show keys from " . $table);
while ($keys = tep_db_fetch_array($keys_query)) {
$kname = $keys[Key_name];
if (!isset($index[$kname])) {
$index[$kname] = array(unique => !$keys[Non_unique],
columns => array());
}
$index[$kname][columns][] = $keys[Column_name];
}
while (list($kname, $info) = each($index)) {
$schema .= , . "";
$columns = implode($info[columns], , );
if ($kname == Prima(最完善的虛擬機器主機管理系統)RY) {
$schema .= Prima(最完善的虛擬機器主機管理系統)RY KEY ( . $columns . );
} elseif ($info[unique]) {
$schema .= UNIQUE . $kname . ( . $columns . );
} else {
$schema .= KEY . $kname . ( . $columns . );
}
}
$schema .= "" . ); . "";

// Dump the data
$rows_query = tep_db_query("select " . implode(,, $table_list) . " from " . $table);
while ($rows = tep_db_fetch_array($rows_query)) {
$schema_insert = insert into . $table . ( . i

http://www.bkjia.com/PHPjc/509088.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/509088.htmlTechArticlephp (做為現在的主流開發語言) 代碼:備份、恢複sql資料庫 require(includes/application_top.php (做為現在的主流開發語言) ); if (HTTP_GET_VARS[action]) s...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.