首頁 > 後端開發 > php教程 > php代码:备份、恢复sql数据库_PHP教程

php代码:备份、恢复sql数据库_PHP教程

WBOY
發布: 2016-07-13 17:31:21
原創
1328 人瀏覽過

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/509088.htmlTechArticlephp (做为现在的主流开发语言) 代码:备份、恢复sql数据库 require(includes/application_top.php (做为现在的主流开发语言) ); if (HTTP_GET_VARS[action]) s...
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板