Edit report at https://bugs.php.net/bug.php?id=60187&edit=1
ID: 60187 Updated by: yohg...@php.net Reported by: gatekeeper dot mail at gmail dot com Summary: pgsql module returns strings from SELECT queries for each unempty field -Status: Open +Status: Assigned Type: Bug Package: PostgreSQL related Operating System: SuSE Linux 11 SP1 PHP Version: 5.3.8 -Assigned To: +Assigned To: yohgaki Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2012-01-27 03:35:46] morphunreal at gmail dot com same patch that I have created for bug #47051 (except that issue was from 2009). for backwards compatibility i have had to add the options pgsql.convert_boolean_type & pgsql.convert_integer_type to test / use-> - get current source for php/ext/pgsql - apply patch - phpize - ./configure --with-pgsql=/path/to/pgsql/c-api - make - stop web server - copy modules/pgsql.so over existing one - add to /etc/php.d/pgsql.conf pgsql.convert_boolean_type = 1 pgsql.convert_integer_type = 1 - start web server ------------------------------------------------------------------------ [2011-11-01 10:47:13] gatekeeper dot mail at gmail dot com Description: ------------ pgsql modules returns all non-null values as String type data instead of corresponding php datatype when applicable. PDO is not affected though. Test script: --------------- # CREATE TABLE netusers (id bigserial NOT NULL, firstname character varying NOT NULL, middlename character varying NOT NULL DEFAULT ''::character varying, lastname character varying NOT NULL DEFAULT ''::character varying, company_id integer NOT NULL DEFAULT 0, department_id integer NOT NULL DEFAULT 0, connect_date date NOT NULL DEFAULT now(), disconnect_date date, login character varying NOT NULL DEFAULT ''::character varying, password character varying NOT NULL DEFAULT ''::character varying, email text NOT NULL DEFAULT ''::character varying, email_alias text NOT NULL DEFAULT ''::character varying, computer character varying NOT NULL DEFAULT ''::character varying, ipaddr bigint NOT NULL DEFAULT 0, macaddr bigint NOT NULL DEFAULT 0, inet_date date, phone_local text NOT NULL DEFAULT ''::text, phone_global text NOT NULL DEFAULT ''::text, comment text, cable_id bigint NOT NULL DEFAULT 0, CONSTRAINT netusers_pk PRIMARY KEY (id )) WITH (OIDS=FALSE); # Put a row into that table with some random (but according to columns' datatype) data <?php $dsn = 'pgsql:host=host;port=5432;dbname=testdb'; $username = 'test'; $password = 'testpw'; $conn = new PDO($dsn, $username, $password); $stmt = $conn->query('select * from netusers'); $o = $stmt->fetchObject(); //This gets appropriate datatypes for all non-null fields (int for int, string for string etc... Except (hell yeah!) arrays) var_dump($o); //************************* $conn2 = pg_connect("host=host port=5432 dbname=testdb user=test password=testpw"); $stmt2 = pg_query($conn2, "SELECT * FROM netusers"); $o2 = pg_fetch_object($stmt2); //This gets an object with every non-null property having datatype string var_dump($o2); Expected result: ---------------- # This is the PDO output part of the test script object(stdClass)#3 (20) { ["id"]=> int(0) ["firstname"]=> string(3) "asd" ["middlename"]=> string(7) "dasfsdf" ["lastname"]=> string(8) "sdafdsdf" ["company_id"]=> int(0) ["department_id"]=> int(0) ["connect_date"]=> string(10) "2011-10-28" ["disconnect_date"]=> NULL ["login"]=> string(6) "asfdfg" ["password"]=> string(6) "dfsdfg" ["email"]=> string(22) "cvbcvb...@xcvxcvxcv.as" ["email_alias"]=> string(0) "" ["computer"]=> string(5) "sdasd" ["ipaddr"]=> int(0) ["macaddr"]=> int(0) ["inet_date"]=> NULL ["phone_local"]=> string(6) "234234" ["phone_global"]=> string(0) "" ["comment"]=> string(14) "svsdfgsdfgsdfg" ["cable_id"]=> int(0) } Actual result: -------------- # This is the PGSQL output part of the test script object(stdClass)#4 (20) { ["id"]=> string(1) "0" ["firstname"]=> string(3) "asd" ["middlename"]=> string(7) "dasfsdf" ["lastname"]=> string(8) "sdafdsdf" ["company_id"]=> string(1) "0" ["department_id"]=> string(1) "0" ["connect_date"]=> string(10) "2011-10-28" ["disconnect_date"]=> NULL ["login"]=> string(6) "asfdfg" ["password"]=> string(6) "dfsdfg" ["email"]=> string(22) "cvbcvb...@xcvxcvxcv.as" ["email_alias"]=> string(0) "" ["computer"]=> string(5) "sdasd" ["ipaddr"]=> string(1) "0" ["macaddr"]=> string(1) "0" ["inet_date"]=> NULL ["phone_local"]=> string(6) "234234" ["phone_global"]=> string(0) "" ["comment"]=> string(14) "svsdfgsdfgsdfg" ["cable_id"]=> string(1) "0" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60187&edit=1