Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TaXOc-00072N-Dw for pgsql-php@postgresql.org; Mon, 19 Nov 2012 19:52:42 +0000 Received: from [2404:130:0:10::82:0] (helo=mail.morphoss.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TaXOW-0007bN-JA for pgsql-php@postgresql.org; Mon, 19 Nov 2012 19:52:40 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.morphoss.com (Postfix) with ESMTP id 939E42200B; Tue, 20 Nov 2012 08:52:29 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at mail.morphoss.com Received: from mail.morphoss.com ([127.0.0.1]) by localhost (hoppy.mcmillan.net.nz [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gcF0jG8W1Yh7; Tue, 20 Nov 2012 08:52:24 +1300 (NZDT) Received: from [192.168.55.25] (home.mcmillan.net.nz [202.160.48.75]) (Authenticated sender: andrew@mail.morphoss.com) by mail.morphoss.com (Postfix) with ESMTPSA id BC8302200A; Tue, 20 Nov 2012 08:52:24 +1300 (NZDT) Message-ID: <1353354743.5803.7.camel@dave.home.mcmillan.net.nz> Subject: Re: How to specify capitalization for column names in pg_fetch_object? From: Andrew McMillan Reply-To: andrew@morphoss.com To: David McMath Cc: pgsql-php@postgresql.org Date: Tue, 20 Nov 2012 08:52:23 +1300 In-Reply-To: <50AA623D.9090400@stanford.edu> References: <50AA623D.9090400@stanford.edu> Organization: Morphoss Ltd Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-+rbmZf3V7kvsXm/CMIn8" X-Mailer: Evolution 3.4.4-1 Mime-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2404:130:0:10::82:0 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201211/2 X-Sequence-Number: 4284 --=-+rbmZf3V7kvsXm/CMIn8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2012-11-19 at 10:45 -0600, David McMath wrote: > Dear List, >=20 > I'm converting a PHP project from using Oracle to using Postgres.=20 > Apparently, pg_fetch_object() wants to create an object with field names= =20 > lowercase by default. In the Oracle analogue, they're uppercase. So=20 > all my code's "$obj->FIELD" references need to change to "$obj->field". >=20 > Is there any way to tell PHP or Postgres to change the default=20 > capitalization? This has nothing to do with PHP, really, though obviously there can be workarounds for this in connection libraries. In PostgreSQL column names are translated to lower case unless they are not enclosed in double-quotes like "column_name". In Oracle column names are translated to upper case unless they are quoted. So one answer would be to explicitly specify the case of the column and to always refer to it in your SQL in double-quotes. > In Perl, I'd use DBI and set FetchHashKeyName to "NAME_uc". In PHP,=20 > we're using "DB" (not MDB2) for the database connections, and I don't=20 > see a similar-looking lever to pull on You should probably use PDO, which has always seemed to be the closest PHP comes to DBI, and look at using the "PDO_CASE_UPPER" flag on connecting to the database. This may do what you want. Cheers, Andrew. --=20 ------------------------------------------------------------------------ andrew (AT) morphoss (DOT) com +64(272)DEBIAN Does the turtle move for you? www.kame.net ------------------------------------------------------------------------ --=-+rbmZf3V7kvsXm/CMIn8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAABCAAGBQJQqo33AAoJEOr8/r+P646/baoP/3kfD67QlwDiEoLZV11tvhug yq6TYE2L0daFIHZFgPI5pEa64KeMCZGXCc79QAylEZul+OwNAnHmYTfUn3iqOdal ZdaotbHBPbMQfOYp6DOB6yKrmlge2V5ly68Vq+ha50LGx3bFV904dnYdvypaYckX p5I9s2e/U/lKCKAu/V7krEtDHyQzXb4ttfu/lHmewy7LN6AiFRwI1/CmVFXP/F2x urt5iGZLw2boKKK2/McJbcjzp4jgNVJdK8F/nNCz4GdukENU69ctHkyNVY7koYhn uOKfWg8Vka3FKyFLp8/jXg4LjgogLfSE47puboLDqne9rAcw9I0YayjZ/+iSynds /vmAHdN7CYDRzDs3fRQWAWASBwYNy7oaJRgFiOayu8XrkynBq+c9uDm9BqmWjK6p Mrd7I2JK0JPdhholw89OLv049NkeFgOG0ntPFfEnC0LIw+waKYBomYgXH9+Objia sJTsLDySvyKeYxviN/JKK4UhdhXQjCc/ZoHYh6vRO3BYh+kcYurPOLBeCP45PGb0 TNRFKlEUL6GCgjGcE8iKG0oqV3/EE9PlmGerrdFWJNieQ0hcRS6PArsQKjpqhhzC MUtvr3BfrRAAwBBPLyd6B8KHh2k9QCZUDIkwKDPs7//3L6g8N6FTFN1Jt/LHNOpI D3cTe17YNM0JxcV/zF8H =a3Dg -----END PGP SIGNATURE----- --=-+rbmZf3V7kvsXm/CMIn8--