[thelist] SQLSession to PostgreSQL

Andrew Forsberg andrew at thepander.co.nz
Fri Mar 15 23:06:00 CST 2002

On Sat, 2002-03-16 at 17:33, Andrew McKiernan wrote:
> Dear Evolters,


> 108        $c = 0;
> 109        while ($row = pg_fetch_array($this->queryresult,0))
> 110        {
> 111            $res[$c] = $row[$c];
> 112            $c++;
> 113        }

Try not using $c as an array index to $row. That is causing $res to hold
a column in the row, not the row itself. The mysql version you're
porting from doesn't do this. Since $row is getting replaced on each
while loop there's no need to use any counters with it.

In other words: $res[n] should hold the result of the nth $row. By
specifying $row[$c] you're asking $res to hold the column data from $row
at whatever value $c holds. Try:

110		$res[$c] = $row;
111		$c++;

> 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.

At a guess there are 109 columns in the sample table. :-) When $row[109]
is attempted the program dies.

HTH, and cheers,

More information about the thelist mailing list