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

📄 table.class.php

📁 phpMyAdmin图形界面化操作,我已经配置好了,只要把解要压缩后的文件放到站点下就可以用了
💻 PHP
📖 第 1 页 / 共 4 页
字号:
     * @param   string  $extra      'AUTO_INCREMENT'     * @param   string  $comment    field comment     * @param   array   &$field_primary list of fields for PRIMARY KEY     * @param   string  $index     * @return  string  field specification     */    static function generateFieldSpec($name, $type, $length = '', $attribute = '',        $collation = '', $null = false, $default_type = 'USER_DEFINED',        $default_value = '', $extra = '', $comment = '',        &$field_primary, $index, $default_orig = false)    {        $is_timestamp = strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1;        /**         * @todo include db-name         */        $query = PMA_backquote($name) . ' ' . $type;        if ($length != ''            && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i', $type)) {            $query .= '(' . $length . ')';        }        if ($attribute != '') {            $query .= ' ' . $attribute;        }        if (!empty($collation) && $collation != 'NULL'          && preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) {            $query .= PMA_generateCharsetQueryPart($collation);        }        if ($null !== false) {            if ($null == 'NULL') {                $query .= ' NULL';            } else {                $query .= ' NOT NULL';            }        }                switch ($default_type) {            case 'USER_DEFINED' :                if ($is_timestamp && $default_value === '0') {                    // a TIMESTAMP does not accept DEFAULT '0'                    // but DEFAULT 0 works                    $query .= ' DEFAULT 0';                } elseif ($type == 'BIT') {                    $query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';                } else {                    $query .= ' DEFAULT \'' . PMA_sqlAddslashes($default_value) . '\'';                }                break;            case 'NULL' :            case 'CURRENT_TIMESTAMP' :                $query .= ' DEFAULT ' . $default_type;                break;            case 'NONE' :            default :                break;        }        if (!empty($extra)) {            $query .= ' ' . $extra;            // Force an auto_increment field to be part of the primary key            // even if user did not tick the PK box;             if ($extra == 'AUTO_INCREMENT') {                $primary_cnt = count($field_primary);                if (1 == $primary_cnt) {                    for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {                        //void                    }                    if (isset($field_primary[$j]) && $field_primary[$j] == $index) {                        $query .= ' PRIMARY KEY';                        unset($field_primary[$j]);                    }                // but the PK could contain other columns so do not append                // a PRIMARY KEY clause, just add a member to $field_primary                } else {                    $found_in_pk = false;                    for ($j = 0; $j < $primary_cnt; $j++) {                        if ($field_primary[$j] == $index) {                            $found_in_pk = true;                            break;                        }                    } // end for                    if (! $found_in_pk) {                        $field_primary[] = $index;                    }                }            } // end if (auto_increment)        }        if (!empty($comment)) {            $query .= " COMMENT '" . PMA_sqlAddslashes($comment) . "'";        }        return $query;    } // end function    /**     * Counts and returns (or displays) the number of records in a table     *     * Revision 13 July 2001: Patch for limiting dump size from     * vinay@sanisoft.com & girish@sanisoft.com     *     * @param   string   the current database name     * @param   string   the current table name     * @param   boolean  whether to retain or to displays the result     * @param   boolean  whether to force an exact count     *     * @return  mixed    the number of records if "retain" param is true,     *                   otherwise true     *     * @access  public     */    static public function countRecords($db, $table, $ret = false,         $force_exact = false, $is_view = null)    {        if (isset(PMA_Table::$cache[$db][$table]['ExactRows'])) {            $row_count = PMA_Table::$cache[$db][$table]['ExactRows'];        } else {            $row_count = false;                        if (null === $is_view) {                $is_view = PMA_Table::isView($db, $table);            }                        if (! $force_exact) {                if (! isset(PMA_Table::$cache[$db][$table]['Rows']) && ! $is_view) {                    PMA_Table::$cache[$db][$table] = PMA_DBI_fetch_single_row('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\'');                }                $row_count = PMA_Table::$cache[$db][$table]['Rows'];            }                // for a VIEW, $row_count is always false at this point            if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {                if (! $is_view) {                    $row_count = PMA_DBI_fetch_value(                        'SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.'                        . PMA_backquote($table));                } else {                    // For complex views, even trying to get a partial record                    // count could bring down a server, so we offer an                    // alternative: setting MaxExactCountViews to 0 will bypass                    // completely the record counting for views                        if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {                        $row_count = 0;                    } else {                        // Counting all rows of a VIEW could be too long, so use                        // a LIMIT clause.                        // Use try_query because it can fail (a VIEW is based on                        // a table that no longer exists)                        $result = PMA_DBI_try_query(                            'SELECT 1 FROM ' . PMA_backquote($db) . '.'                                . PMA_backquote($table) . ' LIMIT '                                . $GLOBALS['cfg']['MaxExactCountViews'],                                null, PMA_DBI_QUERY_STORE);                        if (!PMA_DBI_getError()) {                            $row_count = PMA_DBI_num_rows($result);                            PMA_DBI_free_result($result);                        }                    }                }                PMA_Table::$cache[$db][$table]['ExactRows'] = $row_count;            }        }        if ($ret) {            return $row_count;        }        /**         * @deprecated at the moment nowhere is $return = false used         */        // Note: as of PMA 2.8.0, we no longer seem to be using        // PMA_Table::countRecords() in display mode.        echo PMA_formatNumber($row_count, 0);        if ($is_view) {            echo '&nbsp;'                . sprintf($GLOBALS['strViewHasAtLeast'],                    $GLOBALS['cfg']['MaxExactCount'],                    '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]');        }    } // end of the 'PMA_Table::countRecords()' function    /**     * @see PMA_Table::generateFieldSpec()     */    static public function generateAlter($oldcol, $newcol, $type, $length,        $attribute, $collation, $null, $default_type, $default_value,        $extra, $comment = '', &$field_primary, $index, $default_orig)    {        return PMA_backquote($oldcol) . ' '            . PMA_Table::generateFieldSpec($newcol, $type, $length, $attribute,                $collation, $null, $default_type, $default_value, $extra,                $comment, $field_primary, $index, $default_orig);    } // end function    /**     * Inserts existing entries in a PMA_* table by reading a value from an old entry     *     * @param   string  The array index, which Relation feature to check     *                  ('relwork', 'commwork', ...)     * @param   string  The array index, which PMA-table to update     *                  ('bookmark', 'relation', ...)     * @param   array   Which fields will be SELECT'ed from the old entry     * @param   array   Which fields will be used for the WHERE query     *                  (array('FIELDNAME' => 'FIELDVALUE'))     * @param   array   Which fields will be used as new VALUES. These are the important     *                  keys which differ from the old entry.     *                  (array('FIELDNAME' => 'NEW FIELDVALUE'))     * @global  string  relation variable     *     * @author          Garvin Hicking <me@supergarv.de>     */    static public function duplicateInfo($work, $pma_table, $get_fields, $where_fields,      $new_fields)    {        $last_id = -1;        if (isset($GLOBALS['cfgRelation']) && $GLOBALS['cfgRelation'][$work]) {            $select_parts = array();            $row_fields = array();            foreach ($get_fields as $get_field) {                $select_parts[] = PMA_backquote($get_field);                $row_fields[$get_field] = 'cc';            }            $where_parts = array();            foreach ($where_fields as $_where => $_value) {                $where_parts[] = PMA_backquote($_where) . ' = \''                    . PMA_sqlAddslashes($_value) . '\'';            }            $new_parts = array();            $new_value_parts = array();            foreach ($new_fields as $_where => $_value) {                $new_parts[] = PMA_backquote($_where);                $new_value_parts[] = PMA_sqlAddslashes($_value);            }            $table_copy_query = '                SELECT ' . implode(', ', $select_parts) . '                  FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'                  . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '                 WHERE ' . implode(' AND ', $where_parts);            // must use PMA_DBI_QUERY_STORE here, since we execute another            // query inside the loop            $table_copy_rs    = PMA_query_as_cu($table_copy_query, true,                PMA_DBI_QUERY_STORE);            while ($table_copy_row = @PMA_DBI_fetch_assoc($table_copy_rs)) {                $value_parts = array();                foreach ($table_copy_row as $_key => $_val) {                    if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {                        $value_parts[] = PMA_sqlAddslashes($_val);                    }                }                $new_table_query = '                    INSERT IGNORE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db'])                        . '.' . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '                    (' . implode(', ', $select_parts) . ',                     ' . implode(', ', $new_parts) . ')                    VALUES                    (\'' . implode('\', \'', $value_parts) . '\',                     \'' . implode('\', \'', $new_value_parts) . '\')';                PMA_query_as_cu($new_table_query);                $last_id = PMA_DBI_insert_id();            } // end while            PMA_DBI_free_result($table_copy_rs);            return $last_id;        }        return true;    } // end of 'PMA_Table::duplicateInfo()' function    /**     * Copies or renames table     * @todo use RENAME for move operations     *        - would work only if the databases are on the same filesystem,     *          how can we check that? try the operation and     *          catch an error?

⌨️ 快捷键说明

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