2012-02-15 67 views
1

我想將我的數據庫表導出到PHPMyAdmin中的LaTeX。它確實會生成一個「註釋」列,但沒有任何東西放在那裏,儘管我對錶格的幾個字段有評論,我試圖導出。 (當然,我確實有「評論」 - 勾選框)。有沒有人知道這個解決方案,或者這只是PHPMyAdmin(此版本)中的一個錯誤?PHPMyAdmin LaTeX導出不顯示行註釋

我在PHPMyAdmin版本3.3.9.2中使用MySQL 5.5.9。

回答

1

我決定自己編寫下面的PHP腳本來解決這個問題。它從數據庫中的所有MySQL表中生成LaTeX表,併爲行名指定一個字段列,併爲註釋指定一個描述列。該代碼不包含MySQL連接邏輯。它可以是你的文檔中的一個很好的補充,可以使用MySQLWorkbench進行圖形化方案。要在網絡瀏覽器中顯示良好,請使用nl2br()

function showDescriptions(){ 
    $result = ""; 
    $tables = mysql_query("SHOW TABLES"); 
    while($table = mysql_fetch_row($tables)){ 
     $columns = mysql_query("SHOW FULL COLUMNS FROM `".$table[0]."`"); 
     $result .= "\begin{table}[h!] %b!p!\n"; 
     $result .= '\begin{tabular}{|p{0.3\textwidth}|p{0.63\textwidth}|}'."\n"; 
     $result .= "\hline\n"; 
     $result .= "Field & Description\\\\\n"; 
     $result .= "\hline \hline\n"; 
     while($column = mysql_fetch_array($columns)){ 
      $result .= LaTeXSafe($column['Field']); 
      $result .= " & "; 
      $result .= LaTeXSafe($column['Comment']); 
      $result .= "\\\\\n"; 
      $result .= "\hline\n"; 
     } 
     $result .= '\end{tabular}'."\n"; 
     $result .= '\vspace{-7pt}'."\n"; 
     $result .= '\caption{\textit{Field descriptions of table '.$table[0].'}}'."\n"; 
     $result .= '\vspace{-7pt}'."\n"; 
     $result .= '\label{table-'.$table[0].'}'."\n"; 
     $result .= '\end{table}'."\n\n\n"; 
    } 
    return $result; 
} 

function LaTeXSafe($text){ 
    return str_replace("_", "\_", $text); 
} 

我希望對某人有用。