PMA\libraries\plugins\export\ExportMediawiki::exportStructure PHP Метод

exportStructure() публичный Метод

Outputs table's structure
public exportStructure ( string $db, string $table, string $crlf, string $error_url, string $export_mode, string $export_type, boolean $do_relation = false, boolean $do_comments = false, boolean $do_mime = false, boolean $dates = false, array $aliases = [] ) : boolean
$db string database name
$table string table name
$crlf string the end of line sequence
$error_url string the url to go back in case of error
$export_mode string 'create_table','triggers','create_view', 'stand_in'
$export_type string 'server', 'database', 'table'
$do_relation boolean whether to include relation comments
$do_comments boolean whether to include the pmadb-style column comments as comments in the structure; this is deprecated but the parameter is left here because export.php calls exportStructure() also for other export types which use this parameter
$do_mime boolean whether to include mime comments
$dates boolean whether to include creation/update/check dates
$aliases array Aliases of db/table/columns
Результат boolean Whether it succeeded
    public function exportStructure($db, $table, $crlf, $error_url, $export_mode, $export_type, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $aliases = array())
    {
        $db_alias = $db;
        $table_alias = $table;
        $this->initAlias($aliases, $db_alias, $table_alias);
        $output = '';
        switch ($export_mode) {
            case 'create_table':
                $columns = $GLOBALS['dbi']->getColumns($db, $table);
                $columns = array_values($columns);
                $row_cnt = count($columns);
                // Print structure comment
                $output = $this->_exportComment("Table structure for " . PMA\libraries\Util::backquote($table_alias));
                // Begin the table construction
                $output .= "{| class=\"wikitable\" style=\"text-align:center;\"" . $this->_exportCRLF();
                // Add the table name
                if (isset($GLOBALS['mediawiki_caption'])) {
                    $output .= "|+'''" . $table_alias . "'''" . $this->_exportCRLF();
                }
                // Add the table headers
                if (isset($GLOBALS['mediawiki_headers'])) {
                    $output .= "|- style=\"background:#ffdead;\"" . $this->_exportCRLF();
                    $output .= "! style=\"background:#ffffff\" | " . $this->_exportCRLF();
                    for ($i = 0; $i < $row_cnt; ++$i) {
                        $col_as = $columns[$i]['Field'];
                        if (!empty($aliases[$db]['tables'][$table]['columns'][$col_as])) {
                            $col_as = $aliases[$db]['tables'][$table]['columns'][$col_as];
                        }
                        $output .= " | " . $col_as . $this->_exportCRLF();
                    }
                }
                // Add the table structure
                $output .= "|-" . $this->_exportCRLF();
                $output .= "! Type" . $this->_exportCRLF();
                for ($i = 0; $i < $row_cnt; ++$i) {
                    $output .= " | " . $columns[$i]['Type'] . $this->_exportCRLF();
                }
                $output .= "|-" . $this->_exportCRLF();
                $output .= "! Null" . $this->_exportCRLF();
                for ($i = 0; $i < $row_cnt; ++$i) {
                    $output .= " | " . $columns[$i]['Null'] . $this->_exportCRLF();
                }
                $output .= "|-" . $this->_exportCRLF();
                $output .= "! Default" . $this->_exportCRLF();
                for ($i = 0; $i < $row_cnt; ++$i) {
                    $output .= " | " . $columns[$i]['Default'] . $this->_exportCRLF();
                }
                $output .= "|-" . $this->_exportCRLF();
                $output .= "! Extra" . $this->_exportCRLF();
                for ($i = 0; $i < $row_cnt; ++$i) {
                    $output .= " | " . $columns[$i]['Extra'] . $this->_exportCRLF();
                }
                $output .= "|}" . str_repeat($this->_exportCRLF(), 2);
                break;
        }
        // end switch
        return PMA_exportOutputHandler($output);
    }