Hello: I have function like this one
function query($query)
{
if (in_array($query,$this->queries))
{
return $result = $this->results[$query];
}
$this->queries[] = $query;
$result = mysql_query($query);
if ($result)
{
while($row = mysql_fetch_array($result)
{
$this->results[$query][] = $row;
}
//I need to return $result for later use (so I can loop it in while if i need to do so later)
//but problem is that $result is being cleaned up after fetching
}
}
does anybody/anyone know solution?
You are already getting an array of the results in the function so you shouldn’t use
mysql_fetch_assoc. Instead, just loop through the results (assuming there are results):And then use: