ID: 33809 Comment by: alan8 at maths dot topology dot org Reported By: torpedo51 at yahoo dot com Status: No Feedback Bug Type: PostgreSQL related Operating System: Linux 2.6.11 PHP Version: 5.0.3 New Comment:
A successful work-around for this bug is to use quotes. So maybe the bug should just be documented as a feature. The following work-around code works fine. $res = pg_query(...); $colname = pg_field_name($res, $j); pg_fetch_result($res, $i, "\"$colname\""); But if you use this: pg_fetch_result($res, $i, $colname); The functions fails as reported by torpedo51 when there are upper-case characters in the column name. PHP version = 5.1.4. pqsl version = 8.1.4. Previous Comments: ------------------------------------------------------------------------ [2005-07-29 01:00:03] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2005-07-21 22:36:25] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-07-21 19:25:19] torpedo51 at yahoo dot com Sorry - wrong again. Third time's a charm: This is ambiguous but does not produce an error: $sql = "select t1.c1, t2.c1 from..." $intValue1 = pg_fetch_result($rs, $intRow, 'c1'); $intValue2 = pg_fetch_result($rs, $intRow, 'c1'); ------------------------------------------------------------------------ [2005-07-21 19:22:09] torpedo51 at yahoo dot com Description: ------------ Using table aliases when retrieving a column value (for the purpose of resolving column name ambiguity) is producing an "invalid column name" error. This produces the error: $sql = "select t1.c1, t2.c1 from..." $intValue1 = pg_fetch_result($rs, $intRow, 't1.c1'); $intValue2 = pg_fetch_result($rs, $intRow, 't2.c1'); This is ambiguous but does not produce an error: $sql = "select t1.c1, t2.c1 from..." $intValue1 = pg_fetch_result($rs, $intRow, 'A'); $intValue2 = pg_fetch_result($rs, $intRow, 'B'); This is valid: $sql = "select t1.c1 as A, t2.c1 as B from..." $intValue1 = pg_fetch_result($rs, $intRow, 'A'); $intValue2 = pg_fetch_result($rs, $intRow, 'B'); PostGres: 8.0.3 php.ini diff: ShortTags = Off Reproduce code: --------------- $sql = "select t1.c1, t2.c1 from table1 t1, table2 t2"; $rs = pg_query($sql); $intValue = pg_fetch_result($rs, $intRow, 't1.c1'); Expected result: ---------------- I expect to be able to retrieve the columns using the explicit name that includes the table alias. Previous versions did not produce this error. I also ran this same test using mySql (mysql_fetch) which does not produce the error. I also tested this which does not produce the error: $row = pg_fetch_assoc($rs); $intValue1 = $row['t1.c1'] $intValue2 = $row['t2.c1'] Actual result: -------------- [client 127.0.0.2] PHP Warning: pg_fetch_result() [function.pg-fetch-result]: Bad column offset specified in /home/spr/Documents/web/spr/spr4/web/10dev/modules/datasvcs.php on line 210 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33809&edit=1
