Bug #10121 Updated: Case Sensitive Associative Arrays

From: Date: Tue, 22 May 2001 05:05:22 +0000
Subject: Bug #10121 Updated: Case Sensitive Associative Arrays
Groups: php.dev 
Request: Send a blank email to php-dev+get-56175@lists.php.net to get a copy of this message
ID: 10121 Updated by: swm Reported By: dranor@dracon.net Old-Status: Open Status: Closed Bug Type: PostgreSQL related Operating system: PHP Version: 4.0.4pl1 Assigned To: Comments: This query performs exactly as it should. If you had have enclosed the create table columns in quotes, they would have been treated case sensitively (in the create and subsequently in the query) as well as by the associative array. Your query proves this. Previous Comments: --------------------------------------------------------------------------- [2001-04-02 17:49:01] dranor@dracon.net Rereading that last line its a little confusing. If you want to input table or column names as mixed case you need to enclose them in quotes otherwise they are lowered. Then when you make a query you would also need to enclose the query names in quotes as it is also lowered automatically if there are no quotes. However this behavior is not shared by associative arrays in PHP for some reason. --------------------------------------------------------------------------- [2001-04-02 17:27:00] dranor@dracon.net Rereading that last line its a little confusing. If you want to input table or column names as mixed case you need to enclose them in quotes otherwise they are lowered. Then when you make a query you would also need to enclose the query names in quotes as it is also lowered automatically if there are no quotes. However this behavior is not shared by associative arrays in PHP for some reason. --------------------------------------------------------------------------- [2001-04-02 16:11:52] dranor@dracon.net The scenario is described here: mydb=> CREATE TABLE test ( U_Name char(50), U_Pass char(16) ); mydb=> INSERT INTO test values ('Bob', 'password'); query.php: <? $conn = pg_connect("dbname=mydb"); $result = pg_exec($conn, "select U_Name, U_Pass from test") $arr = pg_fetch_array($result, 0); echo "U_Name: " + $arr[U_Name] + " U_Pass: " + $arr[U_Pass] + "<BR>"; echo "u_name: " + $arr[u_name] + " u_pass: " + $arr[u_pass] + "<BR>"; ?> results that are printed:U_Name: U_Pass: u_name: Bob u_pass: password ( arr[0] = Bob, arr[1] = password) U_Name is not being automatically lowercased when using associative arrays. As of v6.1 PostgreSQL lowercases all table names as well as all columns. So searching on mixed case or uppercase names will not work unless they are enclosed in quotes.. --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=10121&edit=2

« previous php.dev (#56175) next »