#33809 [Opn]: pg_fetch_result: table alias produces invalid column result error
| From: | torpedo51 at yahoo dot com | Date: | Thu, 21 Jul 2005 17:24:18 +0000 |
| Subject: | #33809 [Opn]: pg_fetch_result: table alias produces invalid column result error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-82290@lists.php.net to get a copy of this message | ||
ID: 33809
User updated by: torpedo51 at yahoo dot com
Reported By: torpedo51 at yahoo dot com
Status: Open
Bug Type: PostgreSQL related
Operating System: Linux 2.6.11
PHP Version: 5.0.3
New Comment:
Sorry - the second sample in my description wasn't correct.
This is ambiguous but does not produce an error:
$sql = "select t1.c1, t2.c1 from..."
$intValue1 = pg_fetch_result($rs, $intRow, 't1');
$intValue2 = pg_fetch_result($rs, $intRow, 't1');
Previous Comments:
------------------------------------------------------------------------
[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