If you want to prevent foreach() warnings when the variable is not an array, use type hints:
foreach ( (array) $this_array as $key=>$value)
// yada yada
That code will generate no errors if $this_array is currently undefined or empty.
Also, WRT the topic at hand, I've had a function like this in my library for a while now. One thing I changed over time though, was instead of only returning a value, I have an extra argument.. note the args you pass I've already worked out within another part of the object class I have the fetch_all as a method of..
public function fetch_all(array &$rows=NULL)
$rows = $row;
This allows you to have the option to pass an array to the function/method that already has data (say, another sql query) and to add to the resultant rows into one bigger array.
Thus when I go (using my db class)
//get our rows into a new array
$new_array = $this->db->fetch_all();
// add more rows to a previous result from this sql query
Hope that helps.