From:             germ dot van dot eck at gmail dot com
Operating system: Linux, Ubuntu 8.04
PHP version:      5.2.8
PHP Bug Type:     PostgreSQL related
Bug description:  pg_fetch_object does not convert to literal PHP booleans

Description:
------------
Postgresql booleans are internally stored as either 'f' or 't' (False or
True).
On retrieval using pg_fetch_object, they are simply retrieved as PHP
strings, rather than either 0 or 1, or even better, false or true.
This causes that postgresql.
I am not sure, but I think in the data returned by the server, there is
metadata explaining the field types and so they could be automatically
converted to PHP bools.
This is from a bugreport and related forum topic that was made for the
CodeIgniter framework.
Bugreport (slighly unrelated CI bug, but this issue was discussed in the
comments):
http://codeigniter.com/bug_tracker/bug/6303/
Forum topic:
http://codeigniter.com/forums/viewthread/101001/


Reproduce code:
---------------
<?php
$conn_string = "host=testserver dbname=testdb user=foo password=bar";
$dbconn = pg_connect($conn_string);
pg_query('CREATE TABLE test(test boolean)');
pg_query('INSERT INTO test(test) VALUES(TRUE)');
$res = pg_query('SELECT * FROM test');
$obj = pg_fetch_object($res);
echo "\n".$obj->test."\n";
pg_query('DROP TABLE test');
?>


Expected result:
----------------
1

Actual result:
--------------
t

-- 
Edit bug report at http://bugs.php.net/?id=47051&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47051&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47051&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47051&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47051&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47051&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47051&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47051&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47051&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47051&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47051&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47051&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47051&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47051&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47051&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47051&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47051&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47051&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47051&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47051&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47051&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47051&r=mysqlcfg

Reply via email to