[thelist] SQLSession to PostgreSQL

Andrew McKiernan andrew at kephra.com.au
Fri Mar 15 22:34:01 CST 2002

Dear Evolters,

I am trying to convert SQLSession (http://www.php.lt/sqlsession/),
which is a PHP/MySQL session tracking system, to a PostgreSQL database
and have hit a bit of a snag.

I thought I had successfully converted the code but have a problem
with the following message coming from the code
(http://www.otoaustralia.org.au/example/php) :

Warning: Unable to jump to row 0 on PostgreSQL result index 2 in
db.class.php on line 109

This refers to the following function (line numbers added):

105    function &get_result( $sql = '' )
106    {
107        if ($sql) { $this->query($sql); }
108        $c = 0;
109        while ($row = pg_fetch_array($this->queryresult,0))
110        {
111            $res[$c] = $row[$c];
112            $c++;
113        }
114        pg_freeresult($this->queryresult);
115        return $res;
116    }

Which I have converted from the original MySQL:

    function &get_result( $sql = '' )
        if ($sql) { $this->query($sql); }
        $c = 0;
        while ($row = mysql_fetch_assoc($this->queryresult))
            $res[$c] = $row;
        return $res;

It seems that this function should return an array ($res) containing
all the results (ie: $res[0], $res[1] etc) but it will not get past
line 109.

The query itself ($this->queryresult) is:

SELECT * FROM oto_sessions WHERE session_id='0masTm2le9sKMQ8ZghY0'

Which is definitely in the database! Obviously I am doing something
wrong because when I run the original MySQL code on my home system it
works fine. It is only my conversion to POSTGRE that causes a problem.

I hope someone can help because I am fast loosing hair over this.

Andrew McKiernan

PO Box 31
NSW 2146
mailto:design at kephra.com.au

More information about the thelist mailing list