php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #31238 pg_field_is_null fails for column with upper case name
Submitted: 2004-12-22 01:00 UTC Modified: 2004-12-29 14:41 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: phpdevel-no-spam at pv2c dot sk Assigned: sniper (profile)
Status: Not a bug Package: Documentation problem
PHP Version: 4CVS, 5CVS (2004-12-22) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpdevel-no-spam at pv2c dot sk
New email:
PHP Version: OS:

 

 [2004-12-22 01:00 UTC] phpdevel-no-spam at pv2c dot sk
Description:
------------
When calling pg_field_is_null() with 3. parameter the column name and it has upper case letters in it, an error is the result:
"PHP Warning:  pg_field_is_null(): Bad column offset specified in bugtest.php on line 15"

This bug was reproduced using PostgreSQL 7.4.6, PHP 4.3.10
PostgreSQL 7.4.6, PHP 4.3.9
PostgreSQL 7.4.6, PHP 4.3.10
using two different servers.

This bug doesn't occur when the 3. parameter is column offset, or the column name contains only lover case letters.

Reproduce code:
---------------
http://www.pv2c.sk/php/bugtest.zip (1KB)

Included is also a sample db creation script.

Expected result:
----------------
Just want to know if the column is NULL.

Actual result:
--------------
Just an warning.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-22 09:06 UTC] sniper@php.net
I can verify this. It happens because the underlying
PQfnumber() function tolower()'s the passed field name.

You can avoid that by passing the name double-quoted:

- if(pg_field_is_null($res, 0, $field))
+ if(pg_field_is_null($res, 0, "\"$field\""))

I have prepared a patch for this but it's up to the "committee" whether we will fix this in sources or in documentation.

 [2004-12-22 18:32 UTC] iliaa@php.net
This should be documented.
 [2004-12-29 14:41 UTC] vrana@php.net
It's already mentioned at http://www.php.net/manual/en/ref.pgsql.php :
"PostgreSQL automatically folds all identifiers (e.g. table/column names) to lower-case values. To get it to recognize upper-case values, you must always wrap the identifier in quotes."
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Oct 30 02:01:24 2020 UTC