XML exports (experimental)
This commit is contained in:
@@ -16,8 +16,8 @@ $Source$
|
||||
|
||||
2002-04-28 Alexander M. Turek <rabus@users.sourceforge.net>
|
||||
* header.inc.php3, lines 162-170: Improved patch #548696.
|
||||
* lang/*.php3, db_details.php3, tbl_dump.php3:
|
||||
prepared files for XML exports.
|
||||
* db_details.php3, tbl_dump.php3, lang/*.php3,
|
||||
libraries/build_dump.lib.php3: XML exports (experimental).
|
||||
|
||||
2002-04-28 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||
* tbl_properties.php3, line 395: replaced a "require" by an include.
|
||||
|
@@ -555,5 +555,42 @@ if (!defined('PMA_BUILD_DUMP_LIB_INCLUDED')){
|
||||
return TRUE;
|
||||
} // end of the 'PMA_getTableCsv()' function
|
||||
|
||||
|
||||
/**
|
||||
* Outputs the content of a table in XML format
|
||||
*
|
||||
* @param string the database name
|
||||
* @param string the table name
|
||||
* @param string the end of line sequence
|
||||
* @param string the url to go back in case of error
|
||||
* (doesn't work yet)
|
||||
*
|
||||
* @return string the XML data structure on success
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_getTableXML($db, $table, $crlf, $error_url) {
|
||||
$local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
|
||||
$result = @mysql_query($local_query);
|
||||
for ($i = 0; $row = mysql_fetch_array($result, MYSQL_ASSOC); $i++) {
|
||||
$columns[$i] = $row['Field'];
|
||||
}
|
||||
unset($i);
|
||||
mysql_free_result($result);
|
||||
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
|
||||
$result = @mysql_query($local_query);
|
||||
$buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
|
||||
while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$buffer .= ' <' . $table . '>' . $crlf;
|
||||
foreach ($columns as $column) {
|
||||
if ($record[$column]!=NULL) {
|
||||
$buffer .= ' <' . $column . '>' . htmlspecialchars($record[$column])
|
||||
. '</' . $column . '>' . $crlf;
|
||||
}
|
||||
}
|
||||
$buffer .= ' </' . $table . '>';
|
||||
}
|
||||
return $buffer;
|
||||
} // end of the 'PMA_getTableXML()' function
|
||||
} // $__PMA_BUILD_DUMP_LIB__
|
||||
?>
|
||||
|
@@ -273,7 +273,7 @@ else {
|
||||
// 'xml' case
|
||||
else if ($GLOBALS['what'] == 'xml') {
|
||||
// first add the xml tag
|
||||
$dump_buffer .= '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf;
|
||||
$dump_buffer .= '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf . $crlf;
|
||||
// some comments
|
||||
$dump_buffer .= '<!--' . $crlf
|
||||
. '-' . $crlf
|
||||
@@ -286,16 +286,30 @@ else {
|
||||
if (!empty($cfg['Server']['port'])) {
|
||||
$dump_buffer .= ':' . $cfg['Server']['port'];
|
||||
}
|
||||
$formatted_db_name = (isset($use_backquotes))
|
||||
? PMA_backquote($db)
|
||||
: '\'' . $db . '\'';
|
||||
$dump_buffer .= $crlf
|
||||
. '- ' . $strGenTime . ': ' . PMA_localisedDate() . $crlf
|
||||
. '- ' . $strServerVersion . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
|
||||
. '- ' . $strPHPVersion . ': ' . phpversion() . $crlf
|
||||
. '- ' . $strDatabase . ': ' . $formatted_db_name . $crlf
|
||||
. '- ' . $strDatabase . ': \'' . $db . '\'' . $crlf
|
||||
. '-' . $crlf
|
||||
. '-->' . $crlf;
|
||||
. '-->' . $crlf . $crlf;
|
||||
// Now build the structure
|
||||
// todo: Make db and table names XML compatible
|
||||
$dump_buffer .= '<' . $db . '>' . $crlf;
|
||||
if (isset($table_select)) {
|
||||
$tmp_select = implode($table_select, '|');
|
||||
$tmp_select = '|' . $tmp_select . '|';
|
||||
}
|
||||
while ($i < $num_tables) {
|
||||
if (!isset($single)) {
|
||||
$table = mysql_tablename($tables, $i);
|
||||
}
|
||||
if (isset($tmp_select) && is_int(strpos($tmp_select, '|' . $table . '|'))) {
|
||||
$dump_buffer .= PMA_getTableXML($db, $table, $crlf, $err_url) . $crlf;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$dump_buffer .= '</' . $db . '>';
|
||||
}
|
||||
// 'csv' case
|
||||
else {
|
||||
|
Reference in New Issue
Block a user