⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tbl_move_copy.php

📁 WEBGAME源码,有架设说明,只是非常简单
💻 PHP
📖 第 1 页 / 共 2 页
字号:
        }        // garvin: updating bookmarks is not possible since only a single table is moved,        // and not the whole DB.        // if ($cfgRelation['bookmarkwork']) {        //     $remove_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['bookmark'])        //                   . ' SET     dbase = \'' . PMA_sqlAddslashes($target_db) . '\''        //                   . ' WHERE dbase  = \'' . PMA_sqlAddslashes($source_db) . '\'';        //     $rmv_rs    = PMA_query_as_cu($remove_query);        //     unset($rmv_query);        // }        if ($cfgRelation['displaywork']) {            $table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])                            . ' SET     db_name = \'' . PMA_sqlAddslashes($target_db) . '\', '                            . '         table_name = \'' . PMA_sqlAddslashes($target_table) . '\''                            . ' WHERE db_name  = \'' . PMA_sqlAddslashes($source_db) . '\''                            . ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';            $tb_rs    = PMA_query_as_cu($table_query);            unset($table_query);            unset($tb_rs);        }        if ($cfgRelation['relwork']) {            $table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])                            . ' SET     foreign_table = \'' . PMA_sqlAddslashes($target_table) . '\','                            . '         foreign_db = \'' . PMA_sqlAddslashes($target_db) . '\''                            . ' WHERE foreign_db  = \'' . PMA_sqlAddslashes($source_db) . '\''                            . ' AND foreign_table = \'' . PMA_sqlAddslashes($source_table) . '\'';            $tb_rs    = PMA_query_as_cu($table_query);            unset($table_query);            unset($tb_rs);            $table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])                            . ' SET     master_table = \'' . PMA_sqlAddslashes($target_table) . '\','                            . '         master_db = \'' . PMA_sqlAddslashes($target_db) . '\''                            . ' WHERE master_db  = \'' . PMA_sqlAddslashes($source_db) . '\''                            . ' AND master_table = \'' . PMA_sqlAddslashes($source_table) . '\'';            $tb_rs    = PMA_query_as_cu($table_query);            unset($table_query);            unset($tb_rs);        }        // garvin: [TODO] Can't get moving PDFs the right way. The page numbers always        // get screwed up independently from duplication because the numbers do not        // seem to be stored on a per-database basis. Would the author of pdf support        // please have a look at it?        if ($cfgRelation['pdfwork']) {            $table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])                            . ' SET     table_name = \'' . PMA_sqlAddslashes($target_table) . '\','                            . '         db_name = \'' . PMA_sqlAddslashes($target_db) . '\''                            . ' WHERE db_name  = \'' . PMA_sqlAddslashes($source_db) . '\''                            . ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';            $tb_rs    = PMA_query_as_cu($table_query);            unset($table_query);            unset($tb_rs);            /*            $pdf_query = 'SELECT pdf_page_number '                       . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])                       . ' WHERE db_name  = \'' . PMA_sqlAddslashes($target_db) . '\''                       . ' AND table_name = \'' . PMA_sqlAddslashes($target_table) . '\'';            $pdf_rs = PMA_query_as_cu($pdf_query);            while ($pdf_copy_row = PMA_DBI_fetch_assoc($pdf_rs)) {                $table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])                                . ' SET     db_name = \'' . PMA_sqlAddslashes($target_db) . '\''                                . ' WHERE db_name  = \'' . PMA_sqlAddslashes($source_db) . '\''                                . ' AND page_nr = \'' . PMA_sqlAddslashes($pdf_copy_row['pdf_page_number']) . '\'';                $tb_rs    = PMA_query_as_cu($table_query);                unset($table_query);                unset($tb_rs);            }            */        }        $sql_query      .= "\n\n" . $sql_drop_table . ';';    } else {        // garvin: Create new entries as duplicates from old PMA DBs        if ($what != 'dataonly' && !isset($maintain_relations)) {            if ($cfgRelation['commwork']) {                // Get all comments and MIME-Types for current table                $comments_copy_query = 'SELECT                                            column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '                                        FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '                                        WHERE                                            db_name = \'' . PMA_sqlAddslashes($source_db) . '\' AND                                            table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';                $comments_copy_rs    = PMA_query_as_cu($comments_copy_query);                // Write every comment as new copied entry. [MIME]                while ($comments_copy_row = PMA_DBI_fetch_assoc($comments_copy_rs)) {                    $new_comment_query = 'REPLACE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])                                . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '                                . ' VALUES('                                . '\'' . PMA_sqlAddslashes($target_db) . '\','                                . '\'' . PMA_sqlAddslashes($target_table) . '\','                                . '\'' . PMA_sqlAddslashes($comments_copy_row['column_name']) . '\''                                . ($cfgRelation['mimework'] ? ',\'' . PMA_sqlAddslashes($comments_copy_row['comment']) . '\','                                        . '\'' . PMA_sqlAddslashes($comments_copy_row['mimetype']) . '\','                                        . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation']) . '\','                                        . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation_options']) . '\'' : '')                                . ')';                    $new_comment_rs    = PMA_query_as_cu($new_comment_query);                } // end while            }            // duplicating the bookmarks must not be done here, but            // just once per db            $get_fields = array('display_field');            $where_fields = array('db_name' => $source_db, 'table_name' => $source_table);            $new_fields = array('db_name' => $target_db, 'table_name' => $target_table);            PMA_duplicate_table_info('displaywork', 'table_info', $get_fields, $where_fields, $new_fields);            $get_fields = array('master_field', 'foreign_db', 'foreign_table', 'foreign_field');            $where_fields = array('master_db' => $source_db, 'master_table' => $source_table);            $new_fields = array('master_db' => $target_db, 'master_table' => $target_table);            PMA_duplicate_table_info('relwork', 'relation', $get_fields, $where_fields, $new_fields);            $get_fields = array('foreign_field', 'master_db', 'master_table', 'master_field');            $where_fields = array('foreign_db' => $source_db, 'foreign_table' => $source_table);            $new_fields = array('foreign_db' => $target_db, 'foreign_table' => $target_table);            PMA_duplicate_table_info('relwork', 'relation', $get_fields, $where_fields, $new_fields);            // garvin: [TODO] Can't get duplicating PDFs the right way. The page numbers always            // get screwed up independently from duplication because the numbers do not            // seem to be stored on a per-database basis. Would the author of pdf support            // please have a look at it?            /*            $get_fields = array('page_descr');            $where_fields = array('db_name' => $source_db);            $new_fields = array('db_name' => $target_db);            $last_id = PMA_duplicate_table_info('pdfwork', 'pdf_pages', $get_fields, $where_fields, $new_fields);            if (isset($last_id) && $last_id >= 0) {                $get_fields = array('x', 'y');                $where_fields = array('db_name' => $source_db, 'table_name' => $source_table);                $new_fields = array('db_name' => $target_db, 'table_name' => $target_table, 'pdf_page_number' => $last_id);                PMA_duplicate_table_info('pdfwork', 'table_coords', $get_fields, $where_fields, $new_fields);            }            */        }    }}/** * renames table * * @param   string  old tbale name * @param   string  new table name * @return  boolean success */function PMA_table_rename( $old_name, $new_name ){    // Ensure the target is valid    if ( count($GLOBALS['dblist']) > 0      && ! in_array($GLOBALS['db'], $GLOBALS['dblist']) ) {        return false;    }    PMA_DBI_select_db($GLOBALS['db']);    $sql_query = '        ALTER TABLE ' . PMA_backquote($old_name) . '        RENAME ' . PMA_backquote($new_name) . ';';    if ( ! PMA_DBI_query($sql_query) ) {        return false;    }    // garvin: Move old entries from comments to new table    require_once('./libraries/relation.lib.php');    $cfgRelation = PMA_getRelationsParam();    if ( $cfgRelation['commwork'] ) {        $remove_query = '            UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '               SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'             WHERE db_name  = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'               AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';        PMA_query_as_cu($remove_query);        unset($remove_query);    }    if ( $cfgRelation['displaywork'] ) {        $table_query = '            UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . '               SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'             WHERE db_name  = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'               AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';        PMA_query_as_cu($table_query);        unset($table_query);    }    if ( $cfgRelation['relwork'] ) {        $table_query = '            UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '            SET     foreign_table = \'' . PMA_sqlAddslashes($new_name) . '\'            WHERE foreign_db  = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'            AND foreign_table = \'' . PMA_sqlAddslashes($old_name) . '\'';        PMA_query_as_cu($table_query);        $table_query = '            UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '               SET     master_table = \'' . PMA_sqlAddslashes($new_name) . '\'             WHERE master_db  = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'               AND master_table = \'' . PMA_sqlAddslashes($old_name) . '\'';        PMA_query_as_cu($table_query);        unset($table_query);    }    if ( $cfgRelation['pdfwork'] ) {        $table_query = '            UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . '               SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'             WHERE db_name  = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'               AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';        PMA_query_as_cu($table_query);        unset($table_query);    }    return true;}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -