Ok, one or two things wrong with the class.
PHP Code:
$output = mysql_query($this->query=$in_query)or die(mysql_error());
return $output;
Pointless variable, just uses up memory albeit not alot but it all adds up:
PHP Code:
return mysql_query($this->query=$in_query)or die(mysql_error());
Would produce the same effect.
Also:
PHP Code:
function fetch($this->query($in_query),$field)) {
while($row = mysql_fetch_assoc($this->query($in_query)) {
echo $row['$field'];
}
You cant do that within function parameters and also if it did work, it would be useless as you call the same function within the body of the function.
Also each time your while loop loops, you are calling a query and getting a new resource, which will loop infinitely over the top entry in the table.
This will accomplish the same thing without looping infinitely
PHP Code:
function fetch($in_query, $field) {
$res = $this->query($in_query);
while($row = mysql_fetch_assoc($res)) {
echo $row[$field] ;
}
}
As to your actual question, do you mean something like this:
PHP Code:
function fetch($in_query) {
$res = $this->query($in_query);
$retArr = array();
while($row = mysql_fetch_assoc($res)) {
$retArr[] = $row;
}
return $retArr;
}
That fetches all the rows from the result set.