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

📄 table.class.php

📁 phpMyAdmin图形界面化操作,我已经配置好了,只要把解要压缩后的文件放到站点下就可以用了
💻 PHP
📖 第 1 页 / 共 4 页
字号:
                                            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($GLOBALS['cfgRelation']['column_info'])                                    . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '                                    . ' VALUES('                                    . '\'' . PMA_sqlAddslashes($target_db) . '\','                                    . '\'' . PMA_sqlAddslashes($target_table) . '\','                                    . '\'' . PMA_sqlAddslashes($comments_copy_row['column_name']) . '\''                                    . ($GLOBALS['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']) . '\'' : '')                                    . ')';                        PMA_query_as_cu($new_comment_query);                    } // end while                    PMA_DBI_free_result($comments_copy_rs);                    unset($comments_copy_rs);                }                // 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_Table::duplicateInfo('displaywork', 'table_info', $get_fields, $where_fields, $new_fields);                /**                 * @todo revise this code when we support cross-db relations                 */                $get_fields = array('master_field', 'foreign_table', 'foreign_field');                $where_fields = array('master_db' => $source_db, 'master_table' => $source_table);                $new_fields = array('master_db' => $target_db, 'foreign_db' => $target_db, 'master_table' => $target_table);                PMA_Table::duplicateInfo('relwork', 'relation', $get_fields, $where_fields, $new_fields);                $get_fields = array('foreign_field', 'master_table', 'master_field');                $where_fields = array('foreign_db' => $source_db, 'foreign_table' => $source_table);                $new_fields = array('master_db' => $target_db, 'foreign_db' => $target_db, 'foreign_table' => $target_table);                PMA_Table::duplicateInfo('relwork', 'relation', $get_fields, $where_fields, $new_fields);                $get_fields = array('x', 'y', 'v', 'h');                $where_fields = array('db_name' => $source_db, 'table_name' => $source_table);                $new_fields = array('db_name' => $target_db, 'table_name' => $target_table);                PMA_Table::duplicateInfo('designerwork', 'designer_coords', $get_fields, $where_fields, $new_fields);                /**                 * @todo garvin: 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_Table::duplicateInfo('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_Table::duplicateInfo('pdfwork', 'table_coords', $get_fields, $where_fields, $new_fields);                }                 */            }        }        return true;    }    /**     * checks if given name is a valid table name,     * currently if not empty, trailing spaces, '.', '/' and '\'     *     * @todo    add check for valid chars in filename on current system/os     * @see     http://dev.mysql.com/doc/refman/5.0/en/legal-names.html     * @param   string  $table_name name to check     * @return  boolean whether the string is valid or not     */    function isValidName($table_name)    {        if ($table_name !== trim($table_name)) {            // trailing spaces            return false;        }        if (! strlen($table_name)) {            // zero length            return false;        }        if (preg_match('/[.\/\\\\]+/i', $table_name)) {            // illegal char . / \            return false;        }        return true;    }    /**     * renames table     *     * @param   string  new table name     * @param   string  new database name     * @return  boolean success     */    function rename($new_name, $new_db = null)    {        if (null !== $new_db && $new_db !== $this->getDbName()) {            // Ensure the target is valid            if (! $GLOBALS['pma']->databases->exists($new_db)) {                $this->errors[] = $GLOBALS['strInvalidDatabase'] . ': ' . $new_db;                return false;            }        } else {            $new_db = $this->getDbName();        }        $new_table = new PMA_Table($new_name, $new_db);        if ($this->getFullName() === $new_table->getFullName()) {            return true;        }        if (! PMA_Table::isValidName($new_name)) {            $this->errors[] = $GLOBALS['strInvalidTableName'] . ': ' . $new_table->getFullName();            return false;        }        $GLOBALS['sql_query'] = '            RENAME TABLE ' . $this->getFullName(true) . '                      TO ' . $new_table->getFullName(true) . ';';        if (! PMA_DBI_query($GLOBALS['sql_query'])) {            $this->errors[] = sprintf($GLOBALS['strErrorRenamingTable'], $this->getFullName(), $new_table->getFullName());            return false;        }        $old_name = $this->getName();        $old_db = $this->getDbName();        $this->setName($new_name);        $this->setDbName($new_db);        /**         * @todo move into extra function PMA_Relation::renameTable($new_name, $old_name, $new_db, $old_db)         */        // garvin: Move old entries from comments to new table        require_once './libraries/relation.lib.php';        $GLOBALS['cfgRelation'] = PMA_getRelationsParam();        if ($GLOBALS['cfgRelation']['commwork']) {            $remove_query = '                UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'                    . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '                   SET `db_name`    = \'' . PMA_sqlAddslashes($new_db) . '\',                       `table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'                 WHERE `db_name`    = \'' . PMA_sqlAddslashes($old_db) . '\'                   AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';            PMA_query_as_cu($remove_query);            unset($remove_query);        }        if ($GLOBALS['cfgRelation']['displaywork']) {            $table_query = '                UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'                    . PMA_backquote($GLOBALS['cfgRelation']['table_info']) . '                   SET `db_name`    = \'' . PMA_sqlAddslashes($new_db) . '\',                       `table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'                 WHERE `db_name`    = \'' . PMA_sqlAddslashes($old_db) . '\'                   AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';            PMA_query_as_cu($table_query);            unset($table_query);        }        if ($GLOBALS['cfgRelation']['relwork']) {            $table_query = '                UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'                    . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '                   SET `foreign_db`    = \'' . PMA_sqlAddslashes($new_db) . '\',                       `foreign_table` = \'' . PMA_sqlAddslashes($new_name) . '\'                 WHERE `foreign_db`    = \'' . PMA_sqlAddslashes($old_db) . '\'                   AND `foreign_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';            PMA_query_as_cu($table_query);            $table_query = '                UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'                    . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '                   SET `master_db`    = \'' . PMA_sqlAddslashes($new_db) . '\',                       `master_table` = \'' . PMA_sqlAddslashes($new_name) . '\'                 WHERE `master_db`    = \'' . PMA_sqlAddslashes($old_db) . '\'                   AND `master_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';            PMA_query_as_cu($table_query);            unset($table_query);        }        if ($GLOBALS['cfgRelation']['pdfwork']) {            $table_query = '                UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'                    . PMA_backquote($GLOBALS['cfgRelation']['table_coords']) . '                   SET `db_name`    = \'' . PMA_sqlAddslashes($new_db) . '\',                       `table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'                 WHERE `db_name`    = \'' . PMA_sqlAddslashes($old_db) . '\'                   AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';            PMA_query_as_cu($table_query);            unset($table_query);        }        if ($GLOBALS['cfgRelation']['designerwork']) {            $table_query = '                UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'                    . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']) . '                   SET `db_name`    = \'' . PMA_sqlAddslashes($new_db) . '\',                       `table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'                 WHERE `db_name`    = \'' . PMA_sqlAddslashes($old_db) . '\'                   AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';            PMA_query_as_cu($table_query);            unset($table_query);        }        $this->messages[] = sprintf($GLOBALS['strRenameTableOK'],            htmlspecialchars($old_name), htmlspecialchars($new_name));        return true;    }    /**     * Get all unique columns     *     * returns an array with all columns with unqiue content, in fact these are     * all columns being single indexed in PRIMARY or UNIQUE     *     * f.e.     *  - PRIMARY(id) // id     *  - UNIQUE(name) // name     *  - PRIMARY(fk_id1, fk_id2) // NONE     *  - UNIQUE(x,y) // NONE     *     *     * @param   boolean whether to quote name with backticks ``     * @return array     */    public function getUniqueColumns($quoted = true)    {        $sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Non_unique = 0';        $uniques = PMA_DBI_fetch_result($sql, array('Key_name', null), 'Column_name');        $return = array();        foreach ($uniques as $index) {            if (count($index) > 1) {                continue;            }            $return[] = $this->getFullName($quoted) . '.' . ($quoted ? PMA_backquote($index[0]) : $index[0]);        }        return $return;    }    /**     * Get all indexed columns     *     * returns an array with all columns make use of an index, in fact only     * first columns in an index     *     * f.e. index(col1, col2) would only return col1     * @param   boolean whether to quote name with backticks ``     * @return array     */    public function getIndexedColumns($quoted = true)    {        $sql = 'SHOW INDEX FROM ' . $this->getFullName(true) . ' WHERE Seq_in_index = 1';        $indexed = PMA_DBI_fetch_result($sql, 'Column_name', 'Column_name');        $return = array();        foreach ($indexed as $column) {            $return[] = $this->getFullName($quoted) . '.' . ($quoted ? PMA_backquote($column) : $column);        }        return $return;    }}?>

⌨️ 快捷键说明

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