function export() { // Silent function to export tab delimited file and force browser to // force the user to save the file. header('Content-Type: application/binary; name=dclexport.txt'); header('Content-Disposition: attachment; filename=dclexport.txt'); $objView =& CreateObject('dcl.boView'); $objView->SetFromURL(); // Make object, run query, and (for now) blindly dump data. The first // record will contain column headings. Any tabs within data will be replaced // by spaces since our fields our tab delimited. $obj = new dclDB(); $obj->Query($objView->GetSQL()); $record = ''; if (count($objView->columnhdrs) > 0) { foreach ($objView->columnhdrs as $val) { $val = str_replace(phpTab, ' ', $val); if ($record != '') { $record .= phpTab; } $record .= $val; } } // Output field headings echo $record . phpCrLf; // Now for the records while ($obj->next_record()) { $record = ''; for ($i = 0; $i < $obj->NumFields(); $i++) { if ($i > 0) { $record .= phpTab; } if ($objView->table == 'tickets' && $obj->GetFieldName($i) == 'seconds') { $record .= str_replace(phpTab, ' ', $obj->GetHoursText()); } else { $sData = str_replace(phpTab, ' ', $obj->f($i)); $sData = str_replace("\r", ' ', $sData); $sData = str_replace("\n", ' ', $sData); $record .= $sData; } } echo $record . phpCrLf; } exit; // Don't output footer }