[ciapug] ADODB - toexport rs2cvs() ?
David Champion
ciapug@cialug.org
Thu, 14 Aug 2003 16:53:42 -0500
David Champion wrote:
> Anyone using the ADODB toexport.inc.php functions? They do a good job of
> basic exports, but one thing I need is to quote around string values...
> as in:
>
> acct,name,addr
> 12345,"Champion, David","123 Main"
> 12346,"Von Ahsen, Barry","456 Maple, apt # 25"
>
> ...Problem is if you don't quote the strings, then you'll end up with
> extra commas. This is something that most other CSV exports to
> automatically, but I don't see it in ADODB.
>
> I might just hack it in and submit it back to ADODB.
>
> -dc
If anyone's willing to test, here's a quick & dirty diff of the
toexport.inc.php, call it with:
_adodb_export($rs,',',',',false,true,'"',',',',',',',true);
the diff:
63c63
< function
_adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote =
'"',$escquote = '"',$replaceNewLine = ' ',$quoteDelim=false)
---
> function
_adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote =
'"',$escquote = '"',$replaceNewLine = ' ')
112,116c112
< if ($quoteDelim) {
< $s .= $quote . implode($quote . $sep . $quote,
$elements) . $quote . $NEWLINE;
< } else {
< $s .= implode($sep, $elements).$NEWLINE;
< }
---
> $s .= implode($sep, $elements).$NEWLINE;