473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 3565
*** 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: comp.lang.tcl | last post by:
I wrote this PHP function in the hopes that it would properly use a TCL proc I wrote about 4 years ago: if (!function_exists('proper_case')) { /** * Ths function will convert a string into a...
4
by: Ignoramus6539 | last post by:
There were some strange requests to my server asking for config.php file (which I do not have in the requested location). I did some investigation. Seems to be a virus written in perl,...
2
by: azmiza | last post by:
Hi friend, I am new in this area. Hope members can help me on my script below. I want to create Previous and Next button but it runs until maximum execution time. Help me <?php #script...
21
nathj
by: nathj | last post by:
Hi, I am currently working on a new site that offers various files for download. The file information is stored in a MySQL database and the page is produced in PHP depending on how the user got...
10
by: sickboy | last post by:
Hey everyone, I am working on a new site, ForceFedTV.com and I have gotten reports that the site runs great on mac, but once loaded on a pc, after clicking a few links then going back to the home...
5
by: sickboy | last post by:
hello, is it possible to do embedded links from a php script? Check out the code below, when I send the test case to the switch, it will not go to the embedded link #clarence2 Any thoughts?...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
3
by: Hazza | last post by:
Hi, I am using PHP and mysql to create a website. I am fairly new to PHP, and thus am grateful to anyone who helps! Firstly I am running a homepage, that displays additional content if a user...
1
George Lft
by: George Lft | last post by:
ok, first of all, i built my register page using dreamweaver tool which the codes haven been out of control. Now i'm thinking that turning over everything - by using this another set of codes. And...
1
by: gnawz | last post by:
Hi guys, I have a couple of php files that perform various tasks. I will use fields in my system and provide code as well I need help as follows: My database contains the fields Category...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.