How is it possible to retrieve the mysql_query from a function? For instance:
class A() {
...
function getAll($l=1) {
...
$result = mysql_query($query);
return $result
}
...
}
$a = new A();
$r = $a -> getAll(2);
while ($row = mysql_fetch_assoc($r)) {
// do something
}
This code above does not work when I return $result from the function. However, when I use the mysql_fetch_assoc function in getAll function, it works perfectly. So basically, my question is how to return a mysql result set from a function?
** EDIT **
I actually get no errors. The while statement used liked above will just not execute. But the query works perfectly when I execute it from within the getAll function.
;afterreturn $result;?mysql_queryline to this and see if it is just erroring out:$result = mysql_query($query) or trigger_error(mysql_error());