fixed some bugs with CSV exportations
This commit is contained in:
@@ -5,6 +5,12 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2001-08-20 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||||
|
* tbl_properties.php3; tbl_dump.php3; lib.inc.php3; lang/*: fixed some bugs
|
||||||
|
with CSV exportations and added a Ms Excel CSV specific choice (because
|
||||||
|
we know Excel does not support <cr> in data). Thanks to
|
||||||
|
Fran<61>ois <outils@altern.org>.
|
||||||
|
|
||||||
2001-08-19 Olivier M<>ller <om@omnis.ch>
|
2001-08-19 Olivier M<>ller <om@omnis.ch>
|
||||||
* db_readdump.php3: if file contains mutiple queries, only show this line:
|
* db_readdump.php3: if file contains mutiple queries, only show this line:
|
||||||
"Your SQL-query has been executed successfully: The content of your file
|
"Your SQL-query has been executed successfully: The content of your file
|
||||||
@@ -40,7 +46,7 @@ $Source$
|
|||||||
netscape3) and an other one with netscape 3 thanks to
|
netscape3) and an other one with netscape 3 thanks to
|
||||||
Fran<61>ois <outils@altern.org>.
|
Fran<61>ois <outils@altern.org>.
|
||||||
* left.php3; lang/*: checks if databases from $cfgServers[1]['only_db']
|
* left.php3; lang/*: checks if databases from $cfgServers[1]['only_db']
|
||||||
exits before displaying them at the left frame and take into account
|
exists before displaying them at the left frame and take into account
|
||||||
the case where there is no usable databases.
|
the case where there is no usable databases.
|
||||||
* Documentation.html: various updates.
|
* Documentation.html: various updates.
|
||||||
|
|
||||||
|
34
lib.inc.php3
34
lib.inc.php3
@@ -191,7 +191,7 @@ if (!defined('__LIB_INC__')){
|
|||||||
else if (isset($cfgServers[$server])) {
|
else if (isset($cfgServers[$server])) {
|
||||||
$cfgServer = $cfgServers[$server];
|
$cfgServer = $cfgServers[$server];
|
||||||
|
|
||||||
// The user can work with only one database
|
// The user can work with only some databases
|
||||||
if (isset($cfgServer['only_db']) && !empty($cfgServer['only_db'])) {
|
if (isset($cfgServer['only_db']) && !empty($cfgServer['only_db'])) {
|
||||||
if (is_array($cfgServer['only_db'])) {
|
if (is_array($cfgServer['only_db'])) {
|
||||||
$dblist = $cfgServer['only_db'];
|
$dblist = $cfgServer['only_db'];
|
||||||
@@ -1539,16 +1539,22 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
|||||||
* @param string the table name
|
* @param string the table name
|
||||||
* @param integer the offset on this table
|
* @param integer the offset on this table
|
||||||
* @param integer the last row to get
|
* @param integer the last row to get
|
||||||
* @param string the separation string
|
* @param string the field separator character
|
||||||
|
* @param string the optionnal "enclosed by" character
|
||||||
* @param string the handler (function) to call. It must accept one
|
* @param string the handler (function) to call. It must accept one
|
||||||
* parameter ($sql_insert)
|
* parameter ($sql_insert)
|
||||||
*
|
*
|
||||||
|
* @global string whether to obtain an excel compatible csv format or a
|
||||||
|
* simple csv one
|
||||||
|
*
|
||||||
* @return boolean always true
|
* @return boolean always true
|
||||||
*/
|
*/
|
||||||
function get_table_csv($db, $table, $limit_from = 0, $limit_to = 0, $sep, $handler)
|
function get_table_csv($db, $table, $limit_from = 0, $limit_to = 0, $sep, $enc_by, $handler)
|
||||||
{
|
{
|
||||||
// Handles the separator character
|
global $what;
|
||||||
if (empty($sep)) {
|
|
||||||
|
// Handles the "separator" and the optionnal "enclosed by" characters
|
||||||
|
if (empty($sep) || $what == 'excel') {
|
||||||
$sep = ';';
|
$sep = ';';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1557,6 +1563,15 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
|||||||
}
|
}
|
||||||
$sep = str_replace('\\t', "\011", $sep);
|
$sep = str_replace('\\t', "\011", $sep);
|
||||||
}
|
}
|
||||||
|
if (empty($enc_by) || $what == 'excel') {
|
||||||
|
$enc_by = '"';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (get_magic_quotes_gpc()) {
|
||||||
|
$enc_by = stripslashes($enc_by);
|
||||||
|
}
|
||||||
|
$enc_by = str_replace('"', '"', $enc_by);
|
||||||
|
}
|
||||||
|
|
||||||
// Defines the offsets to use
|
// Defines the offsets to use
|
||||||
if ($limit_from > 0) {
|
if ($limit_from > 0) {
|
||||||
@@ -1584,6 +1599,15 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
|
|||||||
$schema_insert .= 'NULL';
|
$schema_insert .= 'NULL';
|
||||||
}
|
}
|
||||||
else if ($row[$j] != '') {
|
else if ($row[$j] != '') {
|
||||||
|
if ($what == 'excel') {
|
||||||
|
$row[$j] = ereg_replace("\015(\012)?", "\012", $row[$j]);
|
||||||
|
$re_test = "$enc_by|$sep|\012";
|
||||||
|
} else {
|
||||||
|
$re_test = "[$enc_by$sep]";
|
||||||
|
}
|
||||||
|
if (ereg($re_test, $row[$j])) {
|
||||||
|
$row[$j] = $enc_by . str_replace($enc_by, $enc_by . $enc_by, $row[$j]) . $enc_by;
|
||||||
|
}
|
||||||
$schema_insert .= $row[$j];
|
$schema_insert .= $row[$j];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -44,7 +44,9 @@ function my_csvhandler($sql_insert)
|
|||||||
global $tmp_buffer;
|
global $tmp_buffer;
|
||||||
|
|
||||||
// Handles the EOL character
|
// Handles the EOL character
|
||||||
if (empty($add_character)) {
|
if ($GLOBALS['what'] == 'excel') {
|
||||||
|
$add_character = "\r\n";
|
||||||
|
} else if (empty($add_character)) {
|
||||||
$add_character = $GLOBALS['crlf'];
|
$add_character = $GLOBALS['crlf'];
|
||||||
} else {
|
} else {
|
||||||
if (get_magic_quotes_gpc()) {
|
if (get_magic_quotes_gpc()) {
|
||||||
@@ -118,7 +120,7 @@ else {
|
|||||||
$ext = 'bz2';
|
$ext = 'bz2';
|
||||||
} else if (isset($gzip) && $gzip == 'gzip') {
|
} else if (isset($gzip) && $gzip == 'gzip') {
|
||||||
$ext = 'gz';
|
$ext = 'gz';
|
||||||
} else if ($what == 'csv') {
|
} else if ($what == 'csv' || $what == 'excel') {
|
||||||
$ext = 'csv';
|
$ext = 'csv';
|
||||||
} else {
|
} else {
|
||||||
$ext = 'sql';
|
$ext = 'sql';
|
||||||
@@ -151,7 +153,7 @@ if ($num_tables == 0) {
|
|||||||
// At least on table -> do the work
|
// At least on table -> do the work
|
||||||
else {
|
else {
|
||||||
// No csv format -> add some comments at the top
|
// No csv format -> add some comments at the top
|
||||||
if ($what != 'csv') {
|
if ($what != 'csv' && $what != 'excel') {
|
||||||
$dump_buffer .= '# phpMyAdmin MySQL-Dump' . $crlf
|
$dump_buffer .= '# phpMyAdmin MySQL-Dump' . $crlf
|
||||||
. '# version ' . PHPMYADMIN_VERSION . $crlf
|
. '# version ' . PHPMYADMIN_VERSION . $crlf
|
||||||
. '# http://phpwizard.net/phpMyAdmin/' . $crlf
|
. '# http://phpwizard.net/phpMyAdmin/' . $crlf
|
||||||
@@ -216,7 +218,7 @@ else {
|
|||||||
// 'csv' case
|
// 'csv' case
|
||||||
else {
|
else {
|
||||||
$tmp_buffer = '';
|
$tmp_buffer = '';
|
||||||
get_table_csv($db, $table, $limit_from, $limit_to, $separator, 'my_csvhandler');
|
get_table_csv($db, $table, $limit_from, $limit_to, $separator, $enclosed, 'my_csvhandler');
|
||||||
$dump_buffer .= $tmp_buffer;
|
$dump_buffer .= $tmp_buffer;
|
||||||
} // end 'csv case
|
} // end 'csv case
|
||||||
} // end building the dump
|
} // end building the dump
|
||||||
|
@@ -675,8 +675,12 @@ echo "\n";
|
|||||||
<?php echo $strStrucData; ?> <br />
|
<?php echo $strStrucData; ?> <br />
|
||||||
<input type="radio" name="what" value="dataonly" />
|
<input type="radio" name="what" value="dataonly" />
|
||||||
<?php echo $strDataOnly; ?> <br />
|
<?php echo $strDataOnly; ?> <br />
|
||||||
|
<input type="radio" name="what" value="excel" />
|
||||||
|
<?php echo $strStrucExcelCSV; ?> <br />
|
||||||
<input type="radio" name="what" value="csv" />
|
<input type="radio" name="what" value="csv" />
|
||||||
<?php echo $strStrucCSV;?> :<br />
|
<?php echo $strStrucCSV;?> :<br />
|
||||||
|
<?php echo $strFields . ' '. $strEnclosedBy; ?>
|
||||||
|
<input type="text" name="enclosed" size="1" value=""" /> <br />
|
||||||
<?php echo $strFields . ' '. $strTerminatedBy; ?>
|
<?php echo $strFields . ' '. $strTerminatedBy; ?>
|
||||||
<input type="text" name="separator" size="2" value=";" /> <br />
|
<input type="text" name="separator" size="2" value=";" /> <br />
|
||||||
<?php echo $strLines . ' '. $strTerminatedBy; ?>
|
<?php echo $strLines . ' '. $strTerminatedBy; ?>
|
||||||
|
Reference in New Issue
Block a user