Q:

Mysqli while loop returns empty array on obviously non-empty resultset

In PHP, I'm using mysqli, to fetch a resultset from the database.  Upon fetching that resultset, I then hand it off to a function which returns an object.
Given the resultset:

Why does this function:
   /**
     * @param resource|\mysqli_result $result
     * @return array|bool
     */
    public static function getObjectArray($result) {
        if($result === FALSE) {
            return FALSE;
        }
        $func = ((gettype($result) === 'resource') ? 'mysql' : 'mysqli') . '_fetch_object';
        $array = array();
        while($row = $func($result)) {
            $array[] = $row;
        }
        return $array;
    }

return an empty array.  When debugging, it just skips the body of the while loop.  This function has worked without a problem in hundreds of other places, but with this particular resultset, it craps out.
Thanks in advance.

A:

I don't know the details on it, but it appears that the resultset is some sort of implicit pass by reference.  I broke it down to just the part that was breaking and ran some tests, and even if I pass the resultset as a parameter to a function, it sets the data_seek of the original to the end.  I reset this on the resultset that I pass in and it works fine.  If anyone has any insight into what is actually happening, I'd love to have a deeper understanding.
Thanks

