From 5d466b7439e210dcf87f9382bdccbbfa2d3f7c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Sat, 14 Jul 2001 01:11:16 +0000 Subject: [PATCH] Limitation feature for data dumps wasn't working with CSV exports --- ChangeLog | 4 ++++ lib.inc.php3 | 33 +++++++++++++++++++++++++-------- tbl_dump.php3 | 2 +- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 082631103..82a02aedf 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2001-07-13 Loïc Chapeaux + * lib.inc.php3, tbl_dump.php3: limitation feature for data dumps wasn't + working with CSV exports. + 2001-07-13 Loïc Chapeaux * lib.inc.php3, tbl_dump.php3, tbl_properties.php3, translations: added a limitation feature for data dumps thanks to diff --git a/lib.inc.php3 b/lib.inc.php3 index 7e711ea4d..e7351068c 100755 --- a/lib.inc.php3 +++ b/lib.inc.php3 @@ -662,7 +662,7 @@ function get_table_content($db, $table, $limit_from = 0, $limit_to = 0, $handler */ function get_table_content_fast($db, $table, $add_query = '', $handler) { - $result = mysql_query('SELECT * FROM ' . db_name($db) . '.' . tbl_name($table). $add_query) or mysql_die(); + $result = mysql_query('SELECT * FROM ' . db_name($db) . '.' . tbl_name($table) . $add_query) or mysql_die(); if ($result != false) { // Checks whether the field is an integer or not @@ -822,15 +822,20 @@ function count_records($db, $table, $ret = false) /** * Output the content of a table in CSV format * - * @param string the database name - * @param string the table name - * @param string the separation string - * @param string the handler (function) to call. It must accept one parameter - * ($sql_insert) + * @param string the database name + * @param string the table name + * @param integer the offset on this table + * @param integer the last row to get + * @param string the separation string + * @param string the handler (function) to call. It must accept one + * parameter ($sql_insert) * * @return boolean always true + * + * Last revision 14 July 2001: Patch for limiting dump size from + * vinay@sanisoft.com & girish@sanisoft.com */ -function get_table_csv($db, $table, $sep, $handler) +function get_table_csv($db, $table, $limit_from = 0, $limit_to = 0, $sep, $handler) { // Handles the separator character if (empty($sep)) { @@ -843,8 +848,20 @@ function get_table_csv($db, $table, $sep, $handler) $sep = str_replace('\\t', "\011", $sep); } + // Defines the offsets to use + if ($limit_from > 0) { + $limit_from--; + } else { + $limit_from = 0; + } + if ($limit_to > 0 && $limit_from >= 0) { + $add_query = " LIMIT $limit_from, $limit_to"; + } else { + $add_query = ''; + } + // Gets the data from the database - $result = mysql_query('SELECT * FROM ' . db_name($db) . '.' . tbl_name($table)) or mysql_die(); + $result = mysql_query('SELECT * FROM ' . db_name($db) . '.' . tbl_name($table) . $add_query) or mysql_die(); // Format the data $i = 0; diff --git a/tbl_dump.php3 b/tbl_dump.php3 index caea6fc1b..6d76b83a7 100755 --- a/tbl_dump.php3 +++ b/tbl_dump.php3 @@ -164,7 +164,7 @@ else else { // $what != "csv" $tmp_buffer=""; - get_table_csv($db, $table, $separator, "my_csvhandler"); + get_table_csv($db, $table, $limit_from, $limit_to, $separator, "my_csvhandler"); $dump_buffer.=$tmp_buffer; } }