Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pootle server 2011-07-14 22:40:07 +02:00
commit 3f2e057d3c
6 changed files with 222 additions and 218 deletions

View File

@ -769,7 +769,7 @@ function PMA_DBI_get_columns_full($database = null, $table = null,
$sql = 'SHOW FULL COLUMNS FROM '
. PMA_backquote($database) . '.' . PMA_backquote($table);
if (null !== $column) {
$sql .= " LIKE '" . $column . "'";
$sql .= " LIKE '" . PMA_sqlAddSlashes($column, true) . "'";
}
$columns = PMA_DBI_fetch_result($sql, 'Field', null, $link);

View File

@ -123,12 +123,12 @@ function PMA_exportDBCreate($db)
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $CG_FORMATS, $CG_HANDLERS;
$format = cgGetOption("format");
$index = array_search($format, $CG_FORMATS);
if ($index >= 0)
return PMA_exportOutputHandler($CG_HANDLERS[$index]($db, $table, $crlf));
return PMA_exportOutputHandler(sprintf("%s is not supported.", $format));
global $CG_FORMATS, $CG_HANDLERS;
$format = cgGetOption("format");
if (isset($CG_FORMATS[$format])) {
return PMA_exportOutputHandler($CG_HANDLERS[$format]($db, $table, $crlf));
}
return PMA_exportOutputHandler(sprintf("%s is not supported.", $format));
}
/**
@ -138,162 +138,184 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
*/
class TableProperty
{
public $name;
public $type;
public $nullable;
public $key;
public $defaultValue;
public $ext;
function __construct($row)
{
$this->name = trim($row[0]);
$this->type = trim($row[1]);
$this->nullable = trim($row[2]);
$this->key = trim($row[3]);
$this->defaultValue = trim($row[4]);
$this->ext = trim($row[5]);
}
function getPureType()
{
$pos=strpos($this->type, "(");
if ($pos > 0)
return substr($this->type, 0, $pos);
return $this->type;
}
function isNotNull()
{
return $this->nullable == "NO" ? "true" : "false";
}
function isUnique()
{
return $this->key == "PRI" || $this->key == "UNI" ? "true" : "false";
}
function getDotNetPrimitiveType()
{
if (strpos($this->type, "int") === 0) return "int";
if (strpos($this->type, "long") === 0) return "long";
if (strpos($this->type, "char") === 0) return "string";
if (strpos($this->type, "varchar") === 0) return "string";
if (strpos($this->type, "text") === 0) return "string";
if (strpos($this->type, "longtext") === 0) return "string";
if (strpos($this->type, "tinyint") === 0) return "bool";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "unknown";
}
function getDotNetObjectType()
{
if (strpos($this->type, "int") === 0) return "Int32";
if (strpos($this->type, "long") === 0) return "Long";
if (strpos($this->type, "char") === 0) return "String";
if (strpos($this->type, "varchar") === 0) return "String";
if (strpos($this->type, "text") === 0) return "String";
if (strpos($this->type, "longtext") === 0) return "String";
if (strpos($this->type, "tinyint") === 0) return "Boolean";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "Unknown";
}
function getIndexName()
{
if (strlen($this->key)>0)
return "index=\"" . $this->name . "\"";
return "";
}
function isPK()
{
return $this->key=="PRI";
}
function format($pattern)
{
$text=$pattern;
$text=str_replace("#name#", $this->name, $text);
$text=str_replace("#type#", $this->getPureType(), $text);
$text=str_replace("#notNull#", $this->isNotNull(), $text);
$text=str_replace("#unique#", $this->isUnique(), $text);
$text=str_replace("#ucfirstName#", ucfirst($this->name), $text);
$text=str_replace("#dotNetPrimitiveType#", $this->getDotNetPrimitiveType(), $text);
$text=str_replace("#dotNetObjectType#", $this->getDotNetObjectType(), $text);
$text=str_replace("#indexName#", $this->getIndexName(), $text);
return $text;
}
public $name;
public $type;
public $nullable;
public $key;
public $defaultValue;
public $ext;
function __construct($row)
{
$this->name = trim($row[0]);
$this->type = trim($row[1]);
$this->nullable = trim($row[2]);
$this->key = trim($row[3]);
$this->defaultValue = trim($row[4]);
$this->ext = trim($row[5]);
}
function getPureType()
{
$pos=strpos($this->type, "(");
if ($pos > 0)
return substr($this->type, 0, $pos);
return $this->type;
}
function isNotNull()
{
return $this->nullable == "NO" ? "true" : "false";
}
function isUnique()
{
return $this->key == "PRI" || $this->key == "UNI" ? "true" : "false";
}
function getDotNetPrimitiveType()
{
if (strpos($this->type, "int") === 0) return "int";
if (strpos($this->type, "long") === 0) return "long";
if (strpos($this->type, "char") === 0) return "string";
if (strpos($this->type, "varchar") === 0) return "string";
if (strpos($this->type, "text") === 0) return "string";
if (strpos($this->type, "longtext") === 0) return "string";
if (strpos($this->type, "tinyint") === 0) return "bool";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "unknown";
}
function getDotNetObjectType()
{
if (strpos($this->type, "int") === 0) return "Int32";
if (strpos($this->type, "long") === 0) return "Long";
if (strpos($this->type, "char") === 0) return "String";
if (strpos($this->type, "varchar") === 0) return "String";
if (strpos($this->type, "text") === 0) return "String";
if (strpos($this->type, "longtext") === 0) return "String";
if (strpos($this->type, "tinyint") === 0) return "Boolean";
if (strpos($this->type, "datetime") === 0) return "DateTime";
return "Unknown";
}
function getIndexName()
{
if (strlen($this->key)>0)
return "index=\"" . htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8') . "\"";
return "";
}
function isPK()
{
return $this->key=="PRI";
}
function formatCs($text)
{
$text=str_replace("#name#", cgMakeIdentifier($this->name, false), $text);
return $this->format($text);
}
function formatXml($text)
{
$text=str_replace("#name#", htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8'), $text);
$text=str_replace("#indexName#", $this->getIndexName(), $text);
return $this->format($text);
}
function format($text)
{
$text=str_replace("#ucfirstName#", cgMakeIdentifier($this->name), $text);
$text=str_replace("#dotNetPrimitiveType#", $this->getDotNetPrimitiveType(), $text);
$text=str_replace("#dotNetObjectType#", $this->getDotNetObjectType(), $text);
$text=str_replace("#type#", $this->getPureType(), $text);
$text=str_replace("#notNull#", $this->isNotNull(), $text);
$text=str_replace("#unique#", $this->isUnique(), $text);
return $text;
}
}
function handleNHibernateCSBody($db, $table, $crlf)
{
$lines=array();
$result=PMA_DBI_query(sprintf("DESC %s.%s", PMA_backquote($db), PMA_backquote($table)));
if ($result)
{
$tableProperties=array();
while ($row = PMA_DBI_fetch_row($result))
$tableProperties[] = new TableProperty($row);
$lines[] = "using System;";
$lines[] = "using System.Collections;";
$lines[] = "using System.Collections.Generic;";
$lines[] = "using System.Text;";
$lines[] = "namespace ".ucfirst($db);
$lines[] = "{";
$lines[] = " #region ".ucfirst($table);
$lines[] = " public class ".ucfirst($table);
$lines[] = " {";
$lines[] = " #region Member Variables";
foreach ($tableProperties as $tablePropertie)
$lines[] = $tablePropertie->format(" protected #dotNetPrimitiveType# _#name#;");
$lines[] = " #endregion";
$lines[] = " #region Constructors";
$lines[] = " public ".ucfirst($table)."() { }";
$temp = array();
foreach ($tableProperties as $tablePropertie)
if (! $tablePropertie->isPK())
$temp[] = $tablePropertie->format("#dotNetPrimitiveType# #name#");
$lines[] = " public ".ucfirst($table)."(".implode(", ", $temp).")";
$lines[] = " {";
foreach ($tableProperties as $tablePropertie)
if (! $tablePropertie->isPK())
$lines[] = $tablePropertie->format(" this._#name#=#name#;");
$lines[] = " }";
$lines[] = " #endregion";
$lines[] = " #region Public Properties";
foreach ($tableProperties as $tablePropertie)
$lines[] = $tablePropertie->format(" public virtual #dotNetPrimitiveType# _#ucfirstName#\n {\n get {return _#name#;}\n set {_#name#=value;}\n }");
$lines[] = " #endregion";
$lines[] = " }";
$lines[] = " #endregion";
$lines[] = "}";
PMA_DBI_free_result($result);
}
return implode("\n", $lines);
}
function cgMakeIdentifier($str, $ucfirst = true)
{
// remove unsafe characters
$str = preg_replace('/[^\p{L}\p{Nl}_]/u', '', $str);
// make sure first character is a letter or _
if (!preg_match('/^\pL/u', $str)) {
$str = '_' . $str;
}
if ($ucfirst) {
$str = ucfirst($str);
}
return $str;
}
function handleNHibernateXMLBody($db, $table, $crlf)
{
$lines=array();
$lines[] = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$lines[] = "<hibernate-mapping xmlns=\"urn:nhibernate-mapping-2.2\" namespace=\"".ucfirst(htmlspecialchars($db, ENT_COMPAT, 'UTF-8'))."\" assembly=\"".ucfirst(htmlspecialchars($db, ENT_COMPAT, 'UTF-8'))."\">";
$lines[] = " <class name=\"".ucfirst(htmlspecialchars($table, ENT_COMPAT, 'UTF-8'))."\" table=\"".htmlspecialchars($table, ENT_COMPAT, 'UTF-8')."\">";
$result = PMA_DBI_query(sprintf("DESC %s.%s", PMA_backquote($db), PMA_backquote($table)));
if ($result)
{
$tableProperties = array();
while ($row = PMA_DBI_fetch_row($result))
$tableProperties[] = new TableProperty($row);
foreach ($tableProperties as $tablePropertie)
{
if ($tablePropertie->isPK())
$lines[] = $tablePropertie->format(" <id name=\"#ucfirstName#\" type=\"#dotNetObjectType#\" unsaved-value=\"0\">\n <column name=\"#name#\" sql-type=\"#type#\" not-null=\"#notNull#\" unique=\"#unique#\" index=\"PRIMARY\"/>\n <generator class=\"native\" />\n </id>");
else
$lines[] = $tablePropertie->format(" <property name=\"#ucfirstName#\" type=\"#dotNetObjectType#\">\n <column name=\"#name#\" sql-type=\"#type#\" not-null=\"#notNull#\" #indexName#/>\n </property>");
}
PMA_DBI_free_result($result);
}
$lines[]=" </class>";
$lines[]="</hibernate-mapping>";
return implode("\n", $lines);
}
function handleNHibernateCSBody($db, $table, $crlf)
{
$lines=array();
$result=PMA_DBI_query(sprintf("DESC %s.%s", PMA_backquote($db), PMA_backquote($table)));
if ($result)
{
$tableProperties=array();
while ($row = PMA_DBI_fetch_row($result))
$tableProperties[] = new TableProperty($row);
$lines[] = "using System;";
$lines[] = "using System.Collections;";
$lines[] = "using System.Collections.Generic;";
$lines[] = "using System.Text;";
$lines[] = "namespace ".cgMakeIdentifier($db);
$lines[] = "{";
$lines[] = " #region ".cgMakeIdentifier($table);
$lines[] = " public class ".cgMakeIdentifier($table);
$lines[] = " {";
$lines[] = " #region Member Variables";
foreach ($tableProperties as $tablePropertie)
$lines[] = $tablePropertie->formatCs(" protected #dotNetPrimitiveType# _#name#;");
$lines[] = " #endregion";
$lines[] = " #region Constructors";
$lines[] = " public ".cgMakeIdentifier($table)."() { }";
$temp = array();
foreach ($tableProperties as $tablePropertie)
if (! $tablePropertie->isPK())
$temp[] = $tablePropertie->formatCs("#dotNetPrimitiveType# #name#");
$lines[] = " public ".cgMakeIdentifier($table)."(".implode(", ", $temp).")";
$lines[] = " {";
foreach ($tableProperties as $tablePropertie)
if (! $tablePropertie->isPK())
$lines[] = $tablePropertie->formatCs(" this._#name#=#name#;");
$lines[] = " }";
$lines[] = " #endregion";
$lines[] = " #region Public Properties";
foreach ($tableProperties as $tablePropertie)
$lines[] = $tablePropertie->formatCs(" public virtual #dotNetPrimitiveType# #ucfirstName#\n {\n get {return _#name#;}\n set {_#name#=value;}\n }");
$lines[] = " #endregion";
$lines[] = " }";
$lines[] = " #endregion";
$lines[] = "}";
PMA_DBI_free_result($result);
}
return implode("\n", $lines);
}
function cgGetOption($optionName)
{
global $what;
return $GLOBALS[$what . "_" . $optionName];
}
function handleNHibernateXMLBody($db, $table, $crlf)
{
$lines=array();
$lines[] = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$lines[] = "<hibernate-mapping xmlns=\"urn:nhibernate-mapping-2.2\" namespace=\"".cgMakeIdentifier($db)."\" assembly=\"".cgMakeIdentifier($db)."\">";
$lines[] = " <class name=\"".cgMakeIdentifier($table)."\" table=\"".cgMakeIdentifier($table)."\">";
$result = PMA_DBI_query(sprintf("DESC %s.%s", PMA_backquote($db), PMA_backquote($table)));
if ($result)
{
$tableProperties = array();
while ($row = PMA_DBI_fetch_row($result))
$tableProperties[] = new TableProperty($row);
foreach ($tableProperties as $tablePropertie)
{
if ($tablePropertie->isPK())
$lines[] = $tablePropertie->formatXml(" <id name=\"#ucfirstName#\" type=\"#dotNetObjectType#\" unsaved-value=\"0\">\n <column name=\"#name#\" sql-type=\"#type#\" not-null=\"#notNull#\" unique=\"#unique#\" index=\"PRIMARY\"/>\n <generator class=\"native\" />\n </id>");
else
$lines[] = $tablePropertie->formatXml(" <property name=\"#ucfirstName#\" type=\"#dotNetObjectType#\">\n <column name=\"#name#\" sql-type=\"#type#\" not-null=\"#notNull#\" #indexName#/>\n </property>");
}
PMA_DBI_free_result($result);
}
$lines[]=" </class>";
$lines[]="</hibernate-mapping>";
return implode("\n", $lines);
}
function cgGetOption($optionName)
{
global $what;
return $GLOBALS[$what . "_" . $optionName];
}
}
?>

View File

@ -316,9 +316,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
@ -374,8 +371,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$mime_map = PMA_getMIME($db, $table, true);
}
$local_buffer = PMA_texEscape($table);
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'. PMA_expandUserString($GLOBALS['latex_structure_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db))
@ -394,8 +389,8 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
return false;
}
while ($row = PMA_DBI_fetch_assoc($result)) {
$fields = PMA_DBI_get_columns($db, $table);
foreach ($fields as $row) {
$type = $row['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
@ -424,8 +419,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';
}
} else {
$row['Default'] = $row['Default'];
}
$field_name = $row['Field'];
@ -468,7 +461,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
return false;
}
} // end while
PMA_DBI_free_result($result);
$buffer = ' \\end{longtable}' . $crlf;
return PMA_exportOutputHandler($buffer);

View File

@ -95,18 +95,16 @@ function PMA_exportDBCreate($db) {
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $mediawiki_export_struct;
global $mediawiki_export_data;
$result = PMA_DBI_fetch_result("SHOW COLUMNS FROM `" . $db . "`.`" . $table . "`");
$row_cnt = count($result);
$columns = PMA_DBI_get_columns($db, $table);
$columns = array_values($columns);
$row_cnt = count($columns);
$output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n";
$output .= "|+'''" . $table . "'''\n";
$output .= "|- style=\"background:#ffdead;\"\n";
$output .= "! style=\"background:#ffffff\" | \n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $result[$i]['Field'];
$output .= " | " . $columns[$i]['Field'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
@ -116,7 +114,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Type\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $result[$i]['Type'];
$output .= " | " . $columns[$i]['Type'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
@ -126,7 +124,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Null\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $result[$i]['Null'];
$output .= " | " . $columns[$i]['Null'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
@ -136,7 +134,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Default\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $result[$i]['Default'];
$output .= " | " . $columns[$i]['Default'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}
@ -146,7 +144,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$output .= "|- style=\"background:#f9f9f9;\"\n";
$output .= "! style=\"background:#f2f2f2\" | Extra\n";
for ($i = 0; $i < $row_cnt; ++$i) {
$output .= " | " . $result[$i]['Extra'];
$output .= " | " . $columns[$i]['Extra'];
if (($i + 1) != $row_cnt) {
$output .= "\n";
}

View File

@ -251,9 +251,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
@ -318,16 +315,17 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
while ($row = PMA_DBI_fetch_assoc($result)) {
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$field_name = $column['Field'];
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($row['Field']) . '</text:p>'
. '<text:p>' . htmlspecialchars($field_name) . '</text:p>'
. '</table:table-cell>';
// reformat mysql query output
// set or enum types: slashes single quotes inside options
$field_name = $row['Field'];
$type = $row['Type'];
$type = $column['Type'];
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
@ -345,27 +343,27 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
. '</table:table-cell>';
if (!isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';
if (!isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
} else {
$row['Default'] = '';
$column['Default'] = '';
}
} else {
$row['Default'] = $row['Default'];
$column['Default'] = $column['Default'];
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars(($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
. '<text:p>' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
. '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($row['Default']) . '</text:p>'
. '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>'
. '</table:table-cell>';
if ($do_relation && $have_rel) {
@ -399,7 +397,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
} // end while
PMA_DBI_free_result($result);
$GLOBALS['odt_buffer'] .= '</table:table>';
return true;

View File

@ -195,9 +195,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations
if ($do_relation && ! empty($cfgRelation['relation'])) {
@ -251,10 +248,11 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
return false;
}
while ($row = PMA_DBI_fetch_assoc($result)) {
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$text_output = '';
$type = $row['Type'];
$type = $column['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
@ -274,9 +272,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
@ -288,30 +286,28 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
} else {
$row['Default'] = $row['Default'];
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($row['Field'], $unique_keys)) {
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '**' . $fmt_pre;
$fmt_post = $fmt_post . '**';
}
if ($row['Key']=='PRI') {
if ($column['Key']=='PRI') {
$fmt_pre = '//' . $fmt_pre;
$fmt_post = $fmt_post . '//';
}
$text_output .= '|' . $fmt_pre . htmlspecialchars($row['Field']) . $fmt_post;
$text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
$text_output .= '|' . htmlspecialchars($type);
$text_output .= '|' . htmlspecialchars(($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . htmlspecialchars(isset($row['Default']) ? $row['Default'] : '');
$text_output .= '|' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
$field_name = $row['Field'];
$field_name = $column['Field'];
if ($do_relation && $have_rel) {
$text_output .= '|' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '');
@ -329,7 +325,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
return false;
}
} // end while
PMA_DBI_free_result($result);
return true;
}