function dump($return = false, $print = true, $depth = 1)
    {
        $dump = array();
        $dump['count'] = $this->count;
        $dump['results'] = array();
        foreach ((array)$this->records() as $key => $record) {
            if ($record instanceof Resource) {
                $dump['results'][$key] = $record->data();
                foreach ($record->links as $field => $link) {
                    if ($depth < 1) {
                        try {
                            $link_record = $record[$field];
                        } catch (ServerException $e) {
                            $link_record = array('$error' => $e->getMessage());
                        }

                        if ($link_record instanceof Resource) {
                            $dump['results'][$key][$field] = $link_record->dump(true, false, $depth+1);
                        } else {
                            $dump['results'][$key][$field] = $link_record;
                        }
                    }
                }
            }
        }
        if ($dump['results'] && $links = $this->links) {
            $dump['$links'] = $this->dump_links($links);
        }
        if ($dump['count'] > 0) {
            $dump['page'] = $this->page;
        }
        if ($this->pages) {
            $dump['pages'] = $this->pages;
        }
        
        if ($print) {
            return print_r($dump, $return);
        } else {
            return $dump;
        }
    }