#33809 [Opn->Fbk]: pg_fetch_result: table alias produces invalid column result error
| From: | sniper@php.net | Date: | Thu, 21 Jul 2005 20:36:26 +0000 |
| Subject: | #33809 [Opn->Fbk]: pg_fetch_result: table alias produces invalid column result error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-82295@lists.php.net to get a copy of this message | ||
ID: 33809
Updated by: sniper@php.net
Reported By: torpedo51 at yahoo dot com
-Status: Open
+Status: Feedback
Bug Type: PostgreSQL related
Operating System: Linux 2.6.11
PHP Version: 5.0.3
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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