3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Set of functions used to build CSV dumps of tables
12 * @param string Text of comment
14 * @return bool Whether it suceeded
16 function PMA_exportComment($text) {
21 * Outputs export footer
23 * @return bool Whether it suceeded
27 function PMA_exportFooter() {
38 * Outputs export header
40 * @return bool Whether it suceeded
44 function PMA_exportHeader() {
45 global $charset, $charset_of_file;
47 <html xmlns
:o
="urn:schemas-microsoft-com:office:office"
48 xmlns
:x
="urn:schemas-microsoft-com:office:excel"
49 xmlns
="http://www.w3.org/TR/REC-html40">
51 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
54 <meta http
-equiv
="Content-type" content
="text/html;charset=<?php echo isset($charset_of_file) ? $charset_of_file : $charset; ?>" />
55 <style id
="Classeur1_16681_Styles">
61 <div id
="Classeur1_16681" align
=center x
:publishsource
="Excel">
63 <table x
:str border
=0 cellpadding
=0 cellspacing
=0 width
=100% style
='border-collapse: collapse'>
70 * Outputs database header
72 * @param string Database name
74 * @return bool Whether it suceeded
78 function PMA_exportDBHeader($db) {
83 * Outputs database footer
85 * @param string Database name
87 * @return bool Whether it suceeded
91 function PMA_exportDBFooter($db) {
96 * Outputs create database database
98 * @param string Database name
100 * @return bool Whether it suceeded
104 function PMA_exportDBCreate($db) {
109 * Outputs the content of a table in CSV format
111 * @param string the database name
112 * @param string the table name
113 * @param string the end of line sequence
114 * @param string the url to go back in case of error
115 * @param string SQL query for obtaining data
117 * @return bool Whether it suceeded
121 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
124 // Gets the data from the database
125 $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED
);
126 $fields_cnt = PMA_DBI_num_fields($result);
128 // If required, get fields name at the first line
129 if (isset($GLOBALS[$what . '_shownames']) && $GLOBALS[$what . '_shownames'] == 'yes') {
130 $schema_insert = '<tr>';
131 for ($i = 0; $i < $fields_cnt; $i++
) {
132 $schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
134 $schema_insert .= '</tr>';
135 if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
139 while ($row = PMA_DBI_fetch_row($result)) {
140 $schema_insert = '<tr>';
141 for ($j = 0; $j < $fields_cnt; $j++
) {
142 if (!isset($row[$j]) ||
is_null($row[$j])) {
143 $value = $GLOBALS[$what . '_replace_null'];
144 } else if ($row[$j] == '0' ||
$row[$j] != '') {
149 $schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
151 $schema_insert .= '</tr>';
152 if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
154 PMA_DBI_free_result($result);