Re: Associative arrays and case sensitivity
| From: | Tomas V.V.Cox | Date: | Wed, 12 Sep 2001 11:44:54 +0000 |
| Subject: | Re: Associative arrays and case sensitivity | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-1889@lists.php.net to get a copy of this message | ||
Chuck Hagenbuch wrote:
>
> Quoting "Tomas V.V.Cox" <cox@idecnet.com>:
>
> > We are talking about the same thing :-) You know, by default, the driver
> > acts in "performance" mode, but you can switch it in connect to
> > "portability" (normally slower but more portable).
> >
> > $db = DB::connect($dsn, array('optimize' => 'portability'));
> >
> > So, use "portability" to do the lowercasing.
>
> I follow you; I'm still not convinced that this is "portable".
>
Lowercasing column names, this code is universal:
$row = $db->getRow('select * from clients where id=3',
DB_FETCHMODE_ASSOC);
$name = $row['name'];
The only place where this could fail is your example of using column
names to build a query. Something like that?
$row = $db->getRow('select * from clients where id=3',
DB_FETCHMODE_ASSOC);
$keys = array_keys($row);
$sql = "select " . implode(',', $keys) . " from clients";
I had never needed the column names returned by a query to build other
query (you?) and the advantages are many when switching the database.
But ok, I can wait until you urgently need to port your big app from
mysql/postgres to Oracle :-)
Tomas V.V.Cox