Hmm ok, just learning more about this. I actually got this code working (not using webassist code) However I would like to convert to your mysqli server behaviours for code consistency throughout my project (I know I know if it aint broke why fix it). But its a good learning curve.
from the following working code, I cannot just simply replace the mysqli_query with a webassist recordset. And I cannot replace the while loop with a webassist version. Any pointers?
I was think since in the working code there is a $row = mysqli_fetch_assoc (without looking it up on Google this is basically an array counter) So therefore to get a webassist version working I could use: $row = array($rows);
<?php require_once('../Connections/ecartdb.php'); ?>
<?php
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=emails.csv');
$output = fopen('php://output', 'w');
$rows = mysqli_query($ecartdb, 'SELECT NewsLetterEmail FROM newsletter');
while ($row = mysqli_fetch_assoc($rows)) {
fputcsv($output, $row);
}
fclose($output);
?>
ok I got it working, is this the logical way of coding it:
<?php require_once('../Connections/ecartdb.php'); ?>
<?php require_once('../webassist/mysqli/rsobj.php'); ?>
<?php
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=emails.csv');
$output = fopen('php://output', 'w');
$rows = new WA_MySQLi_RS("rows",$ecartdb,0);
$rows->setQuery("SELECT NewsLetterEmail FROM newsletter");
$rows->execute();
while(!$rows->atEnd()) {
$row = array($rows->getColumnVal("NewsLetterEmail"));
fputcsv($output, $row);
$rows->moveNext();
}
$rows->moveFirst(); //return RS to first record
?>