private function Fetch($res, $row_no = null, $offset = null)
    {
        if (is_numeric($row_no)) {
            $limit = 1;
        } else {
            $limit = $this->GetNumRows();
        }

        if (is_numeric($offset)) {
            $c_output = PGSQL_NUM;
        } else {
            $c_output = PGSQL_ASSOC;
        }

        $this->FetchFields($res);

        $i = 0;
        $this->result = array();
        while ($rs = @pg_fetch_array($res, $row_no, $c_output) and $limit > $i) {
            $this->result[$i] = ($offset?$rs[$offset]:$rs);
            $i++;
        }
        @pg_free_result($this->conn);
        return $this->result;
    }