cassell/SQLicious — Issue #27: process function could call query() and free result if no result was setup previously.
Author: cassell
Created: 2012-02-22 05:20:30+00:00
State: open

// new process method
function process($function)
{
if($this->result && $this->numberOfRows > 0)
{
mysql_data_seek($this->result,0); // reset result back to first row

while ($row = mysql_fetch_assoc($this->result))
{
call_user_func($function,$this->loadObject($row));
}
}
else
{
$this->query();
$this->process($function);
$this->freeResult();
}

}

// this way you only need to call query if you need the number of rows outside of the process function.