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

📄 pdf_schema.php

📁 WEBGAME源码,有架设说明,只是非常简单
💻 PHP
📖 第 1 页 / 共 4 页
字号:
        // .   ' AND master_table  IN (' . $intable . ')'        // .   ' AND foreign_table IN (' . $intable . ')';        // $result =  PMA_query_as_cu($sql);        // lem9:        // previous logic was checking master tables and foreign tables        // but I think that looping on every table of the pdf page as a master        // and finding its foreigns is OK (then we can support innodb)        $seen_a_relation = false;        foreach ($alltables AS $one_table) {            $exist_rel = PMA_getForeigners($db, $one_table, '', 'both');            if ($exist_rel) {                $seen_a_relation = true;                foreach ($exist_rel AS $master_field => $rel) {                    // put the foreign table on the schema only if selected                    // by the user                    // (do not use array_search() because we would have to                    // to do a === FALSE and this is not PHP3 compatible)                    if (in_array($rel['foreign_table'], $alltables)) {                        $this->PMA_RT_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field']);                    }                } // end while            } // end if        } // end while        // loic1: also show tables without relations        // $norelations     = TRUE;        // if ($result && PMA_DBI_num_rows($result) > 0) {        // $norelations = FALSE;        // while ($row = PMA_DBI_fetch_assoc($result)) {        // $this->PMA_RT_addRelation($row['master_table'], $row['master_field'], $row['foreign_table'], $row['foreign_field']);        // }        // }        // if ($norelations == FALSE) {        if ($seen_a_relation) {            $this->PMA_RT_drawRelations($change_color);        }        $this->PMA_RT_drawTables($show_info, $change_color);        $this->PMA_RT_showRt();    } // end of the "PMA_RT()" method} // end of the "PMA_RT" classfunction PMA_RT_DOC($alltables){    global $db, $pdf, $orientation, $paper;    // TOC    $pdf->addpage($GLOBALS['orientation']);    $pdf->Cell(0, 9, $GLOBALS['strTableOfContents'], 1, 0, 'C');    $pdf->Ln(15);    $i = 1;    foreach ($alltables AS $table) {        $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink();        $pdf->SetX(10);        // $pdf->Ln(1);        $pdf->Cell(0, 6, $GLOBALS['strPageNumber'] . ' {' . sprintf("%02d", $i) . '}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$table]['-']);        $pdf->SetX(10);        $pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']);        // $pdf->Ln(1);        $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');        while ($row = PMA_DBI_fetch_assoc($result)) {            $pdf->SetX(20);            $field_name = $row['Field'];            $pdf->PMA_links['doc'][$table][$field_name] = $pdf->AddLink();            // $pdf->Cell(0, 6, $field_name,0,1,'L',0, $pdf->PMA_links['doc'][$table][$field_name]);        }        $lasttable = $table;        $i++;    }    $pdf->PMA_links['RT']['-'] = $pdf->AddLink();    $pdf->SetX(10);    $pdf->Cell(0, 6, $GLOBALS['strPageNumber'] . ' {00}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$lasttable]['-']);    $pdf->SetX(10);    $pdf->Cell(0, 6, $i . ' ' . $GLOBALS['strRelationalSchema'], 0, 1, 'L', 0, $pdf->PMA_links['RT']['-']);    $z = 0;    foreach ($alltables AS $table) {        $z++;        $pdf->addpage($GLOBALS['orientation']);        $pdf->Bookmark($table);        $pdf->SetAlias('{' . sprintf("%02d", $z) . '}', $pdf->PageNo()) ;        $pdf->PMA_links['RT'][$table]['-'] = $pdf->AddLink();        $pdf->SetLink($pdf->PMA_links['doc'][$table]['-'], -1);        $pdf->SetFont('', 'B', 18);        $pdf->Cell(0, 8, $z . ' ' . $table, 1, 1, 'C', 0, $pdf->PMA_links['RT'][$table]['-']);        $pdf->SetFont('', '', 8);        $pdf->ln();        $cfgRelation = PMA_getRelationsParam();        if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {            $comments = PMA_getComments($db, $table);        }        if ($cfgRelation['mimework']) {            $mime_map = PMA_getMIME($db, $table, true);        }        /**         * Gets table informations         */        $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', null, PMA_DBI_QUERY_STORE);        $showtable = PMA_DBI_fetch_assoc($result);        $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);        $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');        $create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '');        $update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');        $check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');        PMA_DBI_free_result($result);        unset($result);        /**         * Gets table keys and retains them         */        $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');        $primary = '';        $indexes = array();        $lastIndex = '';        $indexes_info = array();        $indexes_data = array();        $pk_array = array(); // will be use to emphasis prim. keys in the table        // view        while ($row = PMA_DBI_fetch_assoc($result)) {            // Backups the list of primary keys            if ($row['Key_name'] == 'PRIMARY') {                $primary .= $row['Column_name'] . ', ';                $pk_array[$row['Column_name']] = 1;            }            // Retains keys informations            if ($row['Key_name'] != $lastIndex) {                $indexes[] = $row['Key_name'];                $lastIndex = $row['Key_name'];            }            $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];            $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];            if (isset($row['Cardinality'])) {                $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];            }            // I don't know what does following column mean....            // $indexes_info[$row['Key_name']]['Packed']          = $row['Packed'];            $indexes_info[$row['Key_name']]['Comment'] = $row['Comment'];            $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];            if (isset($row['Sub_part'])) {                $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];            }        } // end while        if ($result) {            PMA_DBI_free_result($result);        }        /**         * Gets fields properties         */        $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);        $fields_cnt = PMA_DBI_num_rows($result);        // Check if we can use Relations (Mike Beck)        if (!empty($cfgRelation['relation'])) {            // Find which tables are related with the current one and write it in            // an array            $res_rel = PMA_getForeigners($db, $table);            if (count($res_rel) > 0) {                $have_rel = true;            } else {                $have_rel = false;            }        } else {            $have_rel = false;        } // end if        /**         * Displays the comments of the table if MySQL >= 3.23         */        $break = false;        if (!empty($show_comment)) {            $pdf->Cell(0, 3, $GLOBALS['strTableComments'] . ' : ' . $show_comment, 0, 1);            $break = true;        }        if (!empty($create_time)) {            $pdf->Cell(0, 3, $GLOBALS['strStatCreateTime'] . ': ' . $create_time, 0, 1);            $break = true;        }        if (!empty($update_time)) {            $pdf->Cell(0, 3, $GLOBALS['strStatUpdateTime'] . ': ' . $update_time, 0, 1);            $break = true;        }        if (!empty($check_time)) {            $pdf->Cell(0, 3, $GLOBALS['strStatCheckTime'] . ': ' . $check_time, 0, 1);            $break = true;        }        if ($break == true) {            $pdf->Cell(0, 3, '', 0, 1);            $pdf->Ln();        }        $pdf->SetFont('', 'B');        if (isset($orientation) && $orientation == 'L') {            $pdf->Cell(25, 8, ucfirst($GLOBALS['strField']), 1, 0, 'C');            $pdf->Cell(20, 8, ucfirst($GLOBALS['strType']), 1, 0, 'C');            $pdf->Cell(20, 8, ucfirst($GLOBALS['strAttr']), 1, 0, 'C');            $pdf->Cell(10, 8, ucfirst($GLOBALS['strNull']), 1, 0, 'C');            $pdf->Cell(20, 8, ucfirst($GLOBALS['strDefault']), 1, 0, 'C');            $pdf->Cell(25, 8, ucfirst($GLOBALS['strExtra']), 1, 0, 'C');            $pdf->Cell(45, 8, ucfirst($GLOBALS['strLinksTo']), 1, 0, 'C');            if ($paper == 'A4') {                $comments_width = 67;            } else {                // this is really intended for 'letter'                /**                 * @todo find optimal width for all formats                 */                $comments_width = 50;            }            $pdf->Cell($comments_width, 8, ucfirst($GLOBALS['strComments']), 1, 0, 'C');            $pdf->Cell(45, 8, 'MIME', 1, 1, 'C');            $pdf->SetWidths(array(25, 20, 20, 10, 20, 25, 45, $comments_width, 45));        } else {            $pdf->Cell(20, 8, ucfirst($GLOBALS['strField']), 1, 0, 'C');            $pdf->Cell(20, 8, ucfirst($GLOBALS['strType']), 1, 0, 'C');            $pdf->Cell(20, 8, ucfirst($GLOBALS['strAttr']), 1, 0, 'C');            $pdf->Cell(10, 8, ucfirst($GLOBALS['strNull']), 1, 0, 'C');            $pdf->Cell(15, 8, ucfirst($GLOBALS['strDefault']), 1, 0, 'C');            $pdf->Cell(15, 8, ucfirst($GLOBALS['strExtra']), 1, 0, 'C');            $pdf->Cell(30, 8, ucfirst($GLOBALS['strLinksTo']), 1, 0, 'C');            $pdf->Cell(30, 8, ucfirst($GLOBALS['strComments']), 1, 0, 'C');            $pdf->Cell(30, 8, 'MIME', 1, 1, 'C');            $pdf->SetWidths(array(20, 20, 20, 10, 15, 15, 30, 30, 30));        }        $pdf->SetFont('', '');        while ($row = PMA_DBI_fetch_assoc($result)) {            $type = $row['Type'];            // reformat mysql query output - staybyte - 9. June 2001            // loic1: set or enum types: slashes single quotes inside options            if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {                $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);                $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';                $type_nowrap = '';                $binary = 0;                $unsigned = 0;                $zerofill = 0;            } else {                $type_nowrap = ' nowrap="nowrap"';                $type = preg_replace('@BINARY@i', '', $type);                $type = preg_replace('@ZEROFILL@i', '', $type);                $type = preg_replace('@UNSIGNED@i', '', $type);                if (empty($type)) {                    $type = ' ';                }                $binary = stristr($row['Type'], 'BINARY');                $unsigned = stristr($row['Type'], 'UNSIGNED');                $zerofill = stristr($row['Type'], 'ZEROFILL');            }            $strAttribute = ' ';            if ($binary) {                $strAttribute = 'BINARY';            }            if ($unsigned) {                $strAttribute = 'UNSIGNED';            }            if ($zerofill) {                $strAttribute = 'UNSIGNED ZEROFILL';            }            if (!isset($row['Default'])) {                if ($row['Null'] != '' && $row['Null'] != 'NO') {                    $row['Default'] = 'NULL';                }            }            $field_name = $row['Field'];            // $pdf->Ln();            $pdf->PMA_links['RT'][$table][$field_name] = $pdf->AddLink();            $pdf->Bookmark($field_name, 1, -1);            $pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name], -1);            $pdf_row = array($field_name,                $type,                $strAttribute,                ($row['Null'] == '' || $row['Null'] == 'NO') ? $GLOBALS['strNo'] : $GLOBALS['strYes'],                ((isset($row['Default'])) ? $row['Default'] : ''),                $row['Extra'],                ((isset($res_rel[$field_name])) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : ''),                ((isset($comments[$field_name])) ? $comments[$field_name] : ''),                ((isset($mime_map) && isset($mime_map[$field_name])) ? str_replace('_', '/', $mime_map[$field_name]['mimetype']) : '')                );            $links[0] = $pdf->PMA_links['RT'][$table][$field_name];            if (isset($res_rel[$field_name]['foreign_table']) AND                    isset($res_rel[$field_name]['foreign_field']) AND                    isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])                    )            {                $links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']];            } else {                unset($links[6]);            }            $pdf->Row($pdf_row, $links);            /*$pdf->Cell(20, 8, $field_name, 1, 0, 'L', 0, $pdf->PMA_links['RT'][$table][$field_name]);                //echo '    ' . $field_name . ' ' . "\n";            }        $pdf->Cell(20, 8, $type, 1, 0, 'L');        $pdf->Cell(20, 8, $strAttribute, 1, 0, 'L');        $pdf->Cell(15, 8, , 1, 0, 'L');        $pdf->Cell(15, 8, ((isset($row['Default'])) ?  $row['Default'] : ''),1,0,'L');        $pdf->Cell(15, 8, $row['Extra'], 1, 0, 'L');           if ($have_rel) {                if (isset($res_rel[$field_name])) {                    $pdf->Cell(30, 8, $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'],1,0,'L');                }            }            if ($cfgRelation['commwork']) {                if (isset($comments[$field_name])) {                    $pdf->Cell(0, 8, $comments[$field_name], 1, 0, 'L');                }            } */        } // end while        $pdf->SetFont('', '', 14);        PMA_DBI_free_result($result);    } //end each} // end function PMA_RT_DOC/** * Main logic */if (!isset($pdf_page_number)) {    $pdf_page_number = 1;}$show_grid              = (isset($show_grid) && $show_grid == 'on') ? 1 : 0;$show_color             = (isset($show_color) && $show_color == 'on') ? 1 : 0;$show_table_dimension   = (isset($show_table_dimension) && $show_table_dimension == 'on') ? 1 : 0;$all_tab_same_wide      = (isset($all_tab_same_wide) && $all_tab_same_wide == 'on') ? 1 : 0;$with_doc               = (isset($with_doc) && $with_doc == 'on') ? 1 : 0;$orientation            = (isset($orientation) && $orientation == 'P') ? 'P' : 'L';$paper                  = isset($paper) ? $paper : 'A4';PMA_DBI_select_db($db);$rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper);?>

⌨️ 快捷键说明

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