|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-07-21 13:43 UTC] michael at jmslondon dot com
-Status: Open
+Status: Closed
[2010-07-21 13:43 UTC] michael at jmslondon dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 12:00:01 2025 UTC |
Description: ------------ pg_fetch_* returns space string (e.g. ' ') when returning a empty sting ''
Postgres is returning an empty string and pg_fetch is changing the return value.
Empty string is only return if the result is caste as a varchar in the sql 
e.g."SELECT test_thing::varchar". Test script: --------------- //In DB
CREATE TABLE test ( test_thing VARCHAR(5) NOT NULL DEFAULT '');
INSERT INTO test VALUES ('');

//code
$testing = pg_query($db_conn,"SELECT test_thing FROM test WHERE test_thing='');
print_r(pg_fetch_all($testing));
print 'testing'.pg_fetch_result($testing,0,0).'this'; Expected result: ---------------- array(1) {
[0]=
 array(1) {
 ['test_thing']=
 string(0) ''
}
}

testingthis
 Actual result: -------------- array(1) {
[0]=
 array(1) {
 ['test_thing']=
 string(1) ' '
}
}

testing this