Bug #72058 [NEW]: pg_field_num Error with Quoted Aliases
From: klaxian at gmail dot com
Operating system: Debian Linux
PHP version: 5.5.34
Package: PostgreSQL related
Bug Type: Bug
Bug description:pg_field_num Error with Quoted Aliases
Description:
------------
When selecting data from a PostgreSQL database using quoted aliases for
column names (to preserve case, for example), pg_field_num() seems to
expect its input to also contain double quotes. However, returned
values from functions like pg_field_name() and pg_fetch_assoc() do not
contain double quotes. PostgreSQL's own client also does not include
double quotes in the resulting column names. Even if the behavior of
pg_field_num is intentional, there does not seem to be a way to
determine if field aliases have been quoted using the result resource
only.
I suggest fixing pg_field_num() so that it is consistent with the other
PostgreSQL functions. I would expect the function to accept the actual
field name, not encapsulated in double quotes.
Test script:
---------------
$result = pg_query('SELECT \'test\' AS "TeSt"');
var_dump(pg_field_name($result, 0)); // returns TeSt
var_dump(pg_field_num($result, 'TeSt')); // returns -1 (error)
var_dump(pg_field_num($result, '"TeSt"')); // returns 0 (first column)
Expected result:
----------------
I expect pg_field_num($result, 'TeSt') to return 0 instead of an error.
Actual result:
--------------
-1
--
Edit bug report at https://bugs.php.net/bug.php?id=72058&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72058&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72058&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72058&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72058&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72058&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72058&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72058&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72058&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72058&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72058&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72058&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72058&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72058&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72058&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72058&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72058&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72058&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72058&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72058&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72058&r=mysqlcfg
Thread (3 messages)
- klaxian at gmail dot com