I know this is an old post, but I did figure out a way to allow the user to export all the results in a large database in "blocks" using LIMIT - may or may not apply to MySQL only - I only work with MySQL and Oracle. On our server, the number of records that I've capped my block at is 4000 - if this hack is used, you will need to determine the number of records you can successfully export in each block. Here goes.
index.php ............................................................................................................................
In file index.php, look for this bit of code inside the case "search":
[pre]
if ($where_clause != ""){
$sql .= " WHERE ".$where_clause;
} // end if
[/pre]
Immediately following this bit, add the following code:
[pre]
// following gets the limit values from the url which are sent via the block links
if (isset($_GET["csvstart"])) {
$csvstart = $_GET["csvstart"];
} else {
$csvstart = '';
}
if (isset($_GET["csvnorec"])) {
$csvnorec = $_GET["csvnorec"];
} else {
$csvnorec = '';
}
if ((isset($export_to_csv) && $export_to_csv == 1 && $export_to_csv_feature == 1) && ($csvstart != '' && $csvnorec != '')) {
$sql .= " LIMIT ".$csvstart.", ".$csvnorec;
}
[/pre]
Next, look for the spot where it writes the Export to CSV link under the results table:
[pre]
if ( $export_to_csv_feature == 1) {
echo "<a href=\"".$action."?table_name=". urlencode($table_name)."&function=".$function."&where_clause=".urlencode($where_clause_to_pass)."&page=".$page."&order=".urlencode($order)."&order_type=".$order_type."&export_to_csv=1\">";
txt_out ($normal_messages_ar["export_to_csv"]."</a>", "export_to_csv");
echo "</a>";
}
[/pre]
and replace that with this (parts added shown in bold):
[pre]
if ( $export_to_csv_feature == 1) {
$csvincrement = 4000;
if ($results_number > $csvincrement) {
echo "<b style=\"color:#555555;font-weight:normal;\">Export to CSV in sections » </b>";
$csvlinks = build_csv_links($results_number, $action, $where_clause_to_pass, $fields_labels_ar);
echo $csvlinks;
} else {
echo "<a href=\"".$action."?table_name=". urlencode($table_name)."&function=".$function."&where_clause=".urlencode($where_clause_to_pass)."&page=".$page."&order=".urlencode($order)."&order_type=".$order_type."&export_to_csv=1\">";
txt_out ($normal_messages_ar["export_to_csv"], "export_to_csv");
echo '</a>';
} // end display csv export button if record count is >= 4000
}
[/pre]
business_logic.php .............................................................................................................
In business_logic.php, the "build_csv_links" function called in index.php needs to be added. I added mine immediately following the "build_csv" function so they are together in the file.
[pre]
function build_csv_links($results_number, $action, $where_clause_to_pass, $fields_labels_ar)
// build a set of csv export links, starting from a recordset and number of records setting
// input: $res_record, the recordset, $fields_labels_ar
{
global $table_name, $function, $order, $order_type, $csv_separator, $alias_prefix, $csvincrement; // increment set in index.php
$csvlinkno = ceil($results_number / $csvincrement); // get a whole number of blocks required (rounded up to get all)
for ($cl=0; $cl < $csvlinkno; $cl++) {
$csvdispno = $cl + 1;
$csvadd[$cl] = $cl * $csvincrement;
$csvadd1[$cl] = $csvadd[$cl-1] + $csvincrement;
if ($csvadd[$cl] == 0) {
$where_start = $cl;
} else {
$where_start = $csvadd1[$cl];
}
$csvlinkdisp .= " <a href=\"".$action."?table_name=". urlencode($table_name)."&function=".$function."&where_clause=".urlencode($where_clause_to_pass)."&page=0&order=".urlencode($order)."&order_type=".$order_type."&csvstart=".$where_start."&csvnorec=".$csvincrement."&export_to_csv=1\" title=\"Section ".$csvdispno." Export\" style=\"border:1px solid #628ABA;padding:0 3px 1px 3px;\"> ".$csvdispno." </a>";
} // csvstart is the record to start with ... csvnorec is the number of records to get
if ($csvlinkno > 8) { // set here to put the export links on a new line (comment out if not required
$csvlinkdisp = '<div style="margin-top:7px;">'.$csvlinkdisp.'</div>';
return $csvlinkdisp;
} else {
$csvlinkdisp = $csvlinkdisp;
return $csvlinkdisp;
}
} // end function build_csv_links
[/pre]
Hope this helps someone out there - or if someone has found a better way, post back!
Note I've removed some of the indents in the pasted code for readibility.