public function fetch_obj($resource = '') {

        // if no active connection exists, return false
        if (!$this->_connected()) return false;

        // if no resource was specified, and a query was run before, assign the last resource
        if ($resource == '' && isset($this->last_result) && $this->last_result !== false) $resource = & $this->last_result;

        // if $resource is a valid resource, fetch and return next row from the result set
        if ($this->_is_result($resource)) {

            // fetch next row from the result set
            $result = mysqli_fetch_object($resource);

            // if this was an unbuffered query manage setting the value for $returned_rows and some other things
            if ($resource->type == 1) $this->_manage_unbuffered_query_info($resource, $result);

            // return next row, or FALSE if no more rows available
            return $result;

        // if $resource is a pointer to an array taken from cache
        } elseif (is_integer($resource) && isset($this->cached_results[$resource])) {

            // get the current entry from the array
            $result = current($this->cached_results[$resource]);

            // advance the pointer
            next($this->cached_results[$resource]);

            // note that the above could've been done in a single step, using PHP's each() function
            // but it has been deprecated starting with PHP 7.2.0

            // if we're not past the end of the array
            if ($result !== false)

                // cast the resulting array as an object
                $result = (object)$result;

            // return result
            return $result;

        }

        // if $resource is invalid
        // save debug information
        return $this->_log('errors', array(

            'message'   => $this->language['not_a_valid_resource'],

        ));

    }