3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Set of functions used to build XML dumps of tables
12 * @param string Text of comment
14 * @return bool Whether it suceeded
16 function PMA_exportComment($text) {
17 return PMA_exportOutputHandler('<!-- ' . $text . ' -->' . $GLOBALS['crlf']);
21 * Outputs export footer
23 * @return bool Whether it suceeded
27 function PMA_exportFooter() {
32 * Outputs export header
34 * @return bool Whether it suceeded
38 function PMA_exportHeader() {
42 if ($GLOBALS['output_charset_conversion']) {
43 $charset = $GLOBALS['charset_of_file'];
45 $charset = $GLOBALS['charset'];
48 $head = '<?xml version="1.0" encoding="' . $charset . '" ?>' . $crlf
51 . '- phpMyAdmin XML Dump' . $crlf
52 . '- version ' . PMA_VERSION
. $crlf
53 . '- http://www.phpmyadmin.net' . $crlf
55 . '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
56 if (!empty($cfg['Server']['port'])) {
57 $head .= ':' . $cfg['Server']['port'];
60 . '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf
61 . '- ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION
, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION
, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION
, 3) . $crlf
62 . '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf
63 . '-->' . $crlf . $crlf;
64 return PMA_exportOutputHandler($head);
68 * Outputs database header
70 * @param string Database name
72 * @return bool Whether it suceeded
76 function PMA_exportDBHeader($db) {
78 $head = '<!--' . $crlf
79 . '- ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ?
PMA_backquote($db) : '\'' . $db . '\''). $crlf
81 . '<' . $db . '>' . $crlf;
82 return PMA_exportOutputHandler($head);
86 * Outputs database footer
88 * @param string Database name
90 * @return bool Whether it suceeded
94 function PMA_exportDBFooter($db) {
96 return PMA_exportOutputHandler('</' . $db . '>' . $crlf);
100 * Outputs create database database
102 * @param string Database name
104 * @return bool Whether it suceeded
108 function PMA_exportDBCreate($db) {
114 * Outputs the content of a table
116 * @param string the database name
117 * @param string the table name
118 * @param string the end of line sequence
119 * @param string the url to go back in case of error
120 * @param string SQL query for obtaining data
122 * @return bool Whether it suceeded
126 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
127 $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED
);
129 $columns_cnt = PMA_DBI_num_fields($result);
130 for ($i = 0; $i < $columns_cnt; $i++
) {
131 $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
135 $buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
136 if (!PMA_exportOutputHandler($buffer)) return FALSE;
138 while ($record = PMA_DBI_fetch_row($result)) {
139 $buffer = ' <' . $table . '>' . $crlf;
140 for ($i = 0; $i < $columns_cnt; $i++
) {
141 if ( isset($record[$i]) && !is_null($record[$i])) {
142 $buffer .= ' <' . $columns[$i] . '>' . htmlspecialchars($record[$i])
143 . '</' . $columns[$i] . '>' . $crlf;
146 $buffer .= ' </' . $table . '>' . $crlf;
148 if (!PMA_exportOutputHandler($buffer)) return FALSE;
150 PMA_DBI_free_result($result);
153 } // end of the 'PMA_getTableXML()' function