I’ve been using this library for years to make my database interface code database-independent, but I am still discovering new useful functions. Case in point: today I was using the handy rs2csv function, which outputs a recordset to a CSV file with a few lines of code …
$fp = fopen($file, "w");
if ($fp) {
rs2csvfile($rs, $fp);
fclose($fp);
}
But I needed to massage some of the rows in the recordset before writing them to the file. I struggled for a while before finding RSFilter:
$rs2 = RSFilter($rs, 'callbackfunction');
The callback function takes two arguments: the recordset and an array (passed by reference) representing a single row of the recordset (see the example in the link to the documentation above). RSFilter deals with running the function on each row, and returns the duly massaged recordset ready for output to the file.

