471,337 Members | 921 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

php: case-INsensitive variables?

Is there a way to configure PHP to use case-insensitive variable names?
I'd like to do this...

$dbVars = pg_query( $connection, "SELECT columnName1, columnName2,
columnName3 FROM table WHERE id=1" );
$dbVars = pg_fetch_array( $dbVars );
extract( $dbVars[0] );
echo( $columnName1 );

PostgreSQL (and MySQL, to the best of my knowledge) are
case-insensitive, so selecting columnName1 will return columnname1. In
my last project, a 60-table, year-long event, this was just a constant,
numbing (yet minor) source of frustration, and I'd like to avoid it
this next time.

My other option is to use PostgreSQL in a case-sensitive mode, but
there's no switch to just "turn on"; it requires another level of
annoying syntax within the queries, and tweaking PHP seems like a much
better solution.

(apparently PHP2 was case-insensitive, so I hope there's an INI tweak
that will restore this someplace)

Jul 17 '05 #1
3 3384
*** co*****@automatictaxistop.com escribió/wrote (17 Feb 2005 11:58:19
-0800):
PostgreSQL (and MySQL, to the best of my knowledge) are
case-insensitive, so selecting columnName1 will return columnname1.


I can't speak for Postgre but MySQL returns column names using the exact
case you specified.

In any case, I think typing variable names always the same is a good
programming practice that makes code cleaner. Among other things, it
prevents problems like the one you're facing ;-)
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #2
<co*****@automatictaxistop.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
(apparently PHP2 was case-insensitive, so I hope there's an INI tweak
that will restore this someplace)


As far as I know it cannot be done without tweaking the source code. It'd
easier to stick with lowercase-only variable names, then pass the array
through array_change_key_case() before the extraction.
Jul 17 '05 #3
Alvaro G. Vicario wrote:
*** co*****@automatictaxistop.com escribió/wrote (17 Feb 2005 11:58:19
-0800):
PostgreSQL (and MySQL, to the best of my knowledge) are
case-insensitive, so selecting columnName1 will return columnname1.

I can't speak for Postgre but MySQL returns column names using the exact
case you specified.

In any case, I think typing variable names always the same is a good
programming practice that makes code cleaner. Among other things, it
prevents problems like the one you're facing ;-)

MySQL column names are definately case sensitive. You need to pick a
variable/column naming approach that helps to prevent weird and
wonderful problems. I use totally lower case, but others may prefer
diffent methods. Just be consistent - avoids vast amounts of grief <g>
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ignoramus6539 | last post: by
nathj
21 posts views Thread by nathj | last post: by
5 posts views Thread by sickboy | last post: by
George Lft
1 post views Thread by George Lft | last post: by
1 post views Thread by gnawz | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.