Re: [PHP-DB] Re: big/small letters with oracle No2

2004-06-03 Thread Daniel Clark
I've used Oracle for years, and am not aware of Oracle having case sensitive column 
names.


Torsten Lange [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]

 But when using queries on the USER_... data dictionary, Oracle
 delivers always big letters, which is for chemical elements (NA
 vs. Na) or location names (ALICE SPRINGS vs.  Alice Springs) and
 location codes often uncomfortable to read.

 Then I see only one way: create a mapping array to map your field names to
 what you want them to be *really* called.
 
 $mapping = array('FIELD1' = 'My real field name', 'FIELD2' = 'My second
 field name');
 
 Then you get the value this way:
 
 $realName = $mapping[$fieldNameFromDB];

A mapping is the best way.  It separates the internal schema structure
(i.e column names as created by Oracle) from the display values (i.e.
the column names you want to display).

But it is possible to get PHP to return case sensitive column names from
Oracle, see below.

Chris

-

 ?php

 // Example using case sensitive column names in Oracle.
 //
 // Table P1 was created in SQL*Plus using:
 //
 //create table p1 (MyCol number);
 //insert into p1 values (1234);
 //commit;
 //
 // The output of this PHP script is:
 //
 //   array(1) {
 // [MyCol]=
 // string(4) 1234
 //   }

 $conn = OCILogon(scott, tiger, MYDB);

 $query = 'select * from p1';

 $stid = OCIParse($conn, $query);
 OCIExecute($stid);
 OCIFetchInto($stid, $row, OCI_ASSOC);
 echo pre; var_dump($row); echo /pre;

 OCILogoff($conn);

 ?

-- 
Christopher Jones, Oracle Corporation, Australia.




[PHP-DB] Re: big/small letters with oracle No2

2004-06-01 Thread Torsten Roehr
Torsten Lange [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  But when using queries on the USER_... data dictionary, Oracle
 delivers always big letters, which is for
   chemical elements (NA vs. Na) or location names (ALICE SPRINGS vs.
 Alice Springs) and location codes
   often uncomfortable to read.

 It happend in the heat of the moment... The above is only the case for
 column names, i.e. the parameter columns (Na, Mg...). Locations etc.
 belonging of course to data sets.

Hi Torsten,

you can use mb_strtolower() to convert the column names to lower case and
then ucfirst() to make the first letter uppercase:

echo ucfirst(mb_strtolower($fieldname));

Regards,

Torsten Roehr

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: big/small letters with oracle No2

2004-06-01 Thread Torsten Roehr
Torsten Lange [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]


But when using queries on the USER_... data dictionary, Oracle


delivers always big letters, which is for
  chemical elements (NA vs. Na) or location names (ALICE SPRINGS vs.
Alice Springs) and location codes
  often uncomfortable to read.

It happend in the heat of the moment... The above is only the case for
column names, i.e. the parameter columns (Na, Mg...). Locations etc.
belonging of course to data sets.



Hi Torsten,

you can use mb_strtolower() to convert the column names to lower case and
then ucfirst() to make the first letter uppercase:

echo ucfirst(mb_strtolower($fieldname));

Regards,

Torsten Roehr



I know, but there are not only elements but also abbreviations like PCB,
PAK..., which should stay as they are.

Torsten

Then I see only one way: create a mapping array to map your field names to
what you want them to be *really* called.

$mapping = array('FIELD1' = 'My real field name', 'FIELD2' = 'My second
field name');

Then you get the value this way:

$realName = $mapping[$fieldNameFromDB];

Hope this works for you.


Regards, Torsten

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php