X-Original-To: pgsql-php@postgresql.org Received: from localhost (unknown [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 050F7924F31 for ; Mon, 19 May 2003 17:46:22 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 24296-07 for ; Mon, 19 May 2003 17:45:53 -0400 (EDT) Received: from [194.255.119.226] (unknown [194.255.119.226]) by developer.postgresql.org (Postfix) with ESMTP id 1D1819255D2 for ; Mon, 19 May 2003 04:34:31 -0400 (EDT) Received: from no.name.available by [194.255.119.226] via smtpd (for [64.117.224.193]) with ESMTP; Mon, 19 May 2003 10:33:03 +0200 Received: from t26fw.T26.DK (cpe.atm0-0-0-1461144.0x503f98f2.bynxx5.customer.tele.dk [80.63.152.242]) by corp.orioninformationservices.com (8.11.6/8.11.6) with SMTP id h4J8brC26296; Mon, 19 May 2003 10:37:56 +0200 Received: from cpe.atm0-0-0-1461144.0x503f98f2.bynxx5.customer.tele.dk ([80.63.152.242]) by t26fw.T26.DK via smtpd (for [192.168.3.23]) with ESMTP; Mon, 19 May 2003 10:32:38 +0200 Message-ID: <002901c31de1$39026050$0f01a8c0@yugoloth> From: "Jona" To: "David Busby" , References: <005001c31b1b$d7a33450$1100000a@busbydev> Subject: Re: Case insensitivity in column and table names Date: Mon, 19 May 2003 10:32:38 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4920.2300 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/23 X-Sequence-Number: 2028 You could change the key case in the array after having called pg_fetch_array($resource) Use the buildin PHP function: array_change_key_case http://dk.php.net/manual/en/function.array-change-key-case.php Works for me with Firebird, PostGre and MySQL /Jona ----- Original Message ----- From: "David Busby" To: Sent: Thursday, May 15, 2003 9:54 PM Subject: Fw: [PHP] Case insensitivity in column and table names > Patrick, > Could you simply place some strtolower() or strtoupper() in the code? > Or are is it when you do something like `pg_fetch_array($resource);` that it > becomes an issue? > > /B > > > > > ----- Original Message ----- > From: "Patrick Gibson" > To: "Dani Oderbolz" > Cc: > Sent: Thursday, May 15, 2003 10:47 > Subject: Re: [PHP] Case insensitivity in column and table names > > > 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/ > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >