Вы уже получаете массив результатов в функции, поэтому не следует использовать mysql_fetch_assoc
.Вместо этого просто просматривайте результаты (при условии, что они есть):
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_assoc($result)
{
$this->results[$query][] = $row;
}
return $this->results[$query];
}
}
И затем используйте:
$result = query("SELECT * FROM test");
if(count($result) > 0)
{
foreach($result as $key=>$value)
{
// Do what you need to with the rows
}
}