Source for file toexport.inc.php
Documentation is available at toexport.inc.php
* @version V4.93 10 Oct 2006 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
* Code to export recordsets in several formats:
* $s = rs2csv($rs); # comma-separated values
* $s = rs2tab($rs); # tab delimited
// returns a recordset as a csv string
function rs2csv(&$rs,$addtitles=
true)
// writes recordset to csv file
// write recordset as csv string to stdout
$fp =
fopen('php://stdout','wb');
function rs2tab(&$rs,$addtitles=
true)
$fp =
fopen('php://stdout','wb');
function _adodb_export(&$rs,$sep,$sepreplace,$fp=
false,$addtitles=
true,$quote =
'"',$escquote =
'"',$replaceNewLine =
' ')
$escquotequote =
$escquote.
$quote;
$fieldTypes =
$rs->FieldTypesArray();
while(list
(,$o) =
each($fieldTypes)) {
if ($escquote) $v =
str_replace($quote,$escquotequote,$v);
$s .=
implode($sep, $elements).
$NEWLINE;
$hasNumIndex = isset
($rs->fields[0]);
$max =
$rs->FieldCount();
for ($j=
0; $j <
$max; $j++
) {
if ($escquote) $v =
str_replace($quote,$escquotequote,$v);
if (strpos($v,$sep) !==
false ||
strpos($v,$quote) !==
false) $elements[] =
"$quote$v$quote";
} else { // ASSOCIATIVE ARRAY
foreach($rs->fields as $v) {
if (strpos($v,$sep) !==
false ||
strpos($v,$quote) !==
false) $elements[] =
"$quote$v$quote";
$s .=
implode($sep, $elements).
$NEWLINE;
if ($fp &&
($line %
$BUFLINES) ==
0) {
if ($fp ===
true) echo
$s;
if ($fp ===
true) echo
$s;
Documentation generated on Sun, 09 Mar 2008 23:53:35 -0300 by phpDocumentor 1.4.0