DB/pgsql.php diff
| From: | Brian Abent | Date: | Wed, 16 Jan 2002 14:41:53 +0000 |
| Subject: | DB/pgsql.php diff | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-3956@lists.php.net to get a copy of this message | ||
Hello,
There was a problem where pg_fetch_row($result, 0) was called before testing
if there was a row to jump to.
Here is a cvs diff for pgsql.php that I made:
-Brian Abent
Index: pgsql.php
===================================================================
RCS file: /repository/php4/pear/DB/pgsql.php,v
retrieving revision 1.61
diff -r1.61 pgsql.php
604,617c604,619
< $row = pg_fetch_row($result, 0);
< $flags = ($row[0] == 't') ? 'not_null ' : '';
<
< if ($row[1] == 't') {
< $result = pg_exec($this->connection, "SELECT a.adsrc
< FROM pg_attribute f, pg_class tab, pg_type
typ, pg_attrdef a
< WHERE tab.relname = typ.typname AND
typ.typrelid = f.attrelid
< AND f.attrelid = a.adrelid AND f.attname =
'$field_name'
< AND tab.relname = '$table_name'");
< $row = pg_fetch_row($result, 0);
< $num = str_replace('\'', '', $row[0]);
<
< $flags .= "default_$num ";
< }
---
> if (pg_numrows($result)>0) {
> $row = pg_fetch_row($result, 0);
> $flags = ($row[0] == 't') ? 'not_null ' : '';
>
> if ($row[1] == 't') {
> $result = pg_exec($this->connection, "SELECT a.adsrc
> FROM pg_attribute f, pg_class tab,
pg_type typ, pg_attrdef a
> WHERE tab.relname = typ.typname AND
typ.typrelid = f.attrelid
> AND f.attrelid = a.adrelid AND f.attname
= '$field_name'
> AND tab.relname = '$table_name'");
> $row = pg_fetch_row($result, 0);
> $num = str_replace('\'', '', $row[0]);
>
> $flags .= "default_$num ";
> }
> }
811c813
< ?>
\ No newline at end of file
---
> ?>