From: Patrick Gibson <postgres_list@patrickg.com>
To: Dani Oderbolz <oderbolz@ecologic.de>
Cc: pgsql-php@postgresql.org
Subject: Re: Case insensitivity in column and table names
Date: Thu, 15 May 2003 10:47:56 -0700
Message-ID: <BAE920DC.C27D%postgres_list@patrickg.com> (raw)
In-Reply-To: <3EC38E67.3070800@ecologic.de>
On 5/15/03 5:56, Dani Oderbolz wrote:
>> We have encountered a big problem when doing the same thing in Postgres, as
>> Postgres seems to lowercase all the column names. Since associative arrays
>> in PHP *are* case-sensitive, all of our existing code thus breaks with the
>> exact same tables.
>>
> I don“t quite get your point.
> In Postgres 7.3.2 I can do this:
>
> Select MyColumn from MyTable;
> --Works
>
> as well as
> Select mycolumn from mytable;
> --Works as well
>
> Its just that internally postgres stores your object names in lowercase -
> which should not matter to you.
It does matter because when it comes back to PHP, the keys in the array are
lowercase, even though the query specified them as uppercase. In the past
(with MySQL) we've always been able to rely on the database returning keys
in the same case as we specify -- PHP arrays are case sensitive, which is
where the problem comes in.
If we have the query, 'select ID, USERNAME from USERS' with a MySQL
database, we'd get an associate array with 'ID' and 'USERNAME' being the
keys. The same query with Postgres will give us keys of 'id' and 'username',
which is different.
The goal of what we want to do is to be able to use the same code no matter
which database we are using. We ultimately will switch to a lowercase
convention to accommodate Postgres, but I'm trying to find out if that
really is the only option. The quoting technique does not work either
because MySQL handles it differently.
Patrick
---
patrick gibson
http://patrickgibson.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: postgres_list@patrickg.com, oderbolz@ecologic.de
Subject: Re: Case insensitivity in column and table names
In-Reply-To: <BAE920DC.C27D%postgres_list@patrickg.com>
References: <3EC38E67.3070800@ecologic.de> <BAE920DC.C27D%postgres_list@patrickg.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox