# case folding array string keys

- Thread: https://externals.io/message/38289
- Original archive: https://news-web.php.net/php.internals/38289
- Started by Dave Lee on 2008-06-16T17:16:21+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #38289 — Dave Lee — 2008-06-16T17:16:21+00:00

URL: https://externals.io/message/38289#38289

Hi,
I have a patch that I'm hoping might be useful to PHP developers, at least
those using PostgreSQL. The patch provides case folding of string keys
during hash lookups. The need for this comes from ...

We're transitioning from MySQL to PostgreSQL, and like many, we use camel
casing for naming tables and columns in our db. In PostgreSQL, (unquoted)
table and column names are case folded to lower case, so where we currently
have $row['someForeignId'], we would need to rewrite the key to
'someforeignid'. Besides being a lesson that we should use _ naming in the
future, it was clear there was no quick solution, we'd be forced to modify
many lines of code, and possibly end up with less readability. Instead, I
added a caseFold flag to the HashTable struct, which is later checked
in zend_hash_find() where, if configured, case folding of the key is
performed before hash lookup.

My question to the list is, can this functionality be added in a way that
doesn't adversely effect developers who won't use it, but helps us
PostgreSQL users and anyone else who might find it useful?  Judging from my
searches on the subject, it's not an uncommon impedance for PHP/PostgreSQL
users.

thanks,
Dave

---

## #38295 — Christopher Jones — 2008-06-16T20:06:54+00:00

URL: https://externals.io/message/38289#38295 · In reply to: #38289

Dave Lee wrote:
 > Hi,
 > I have a patch that I'm hoping might be useful to PHP developers, at least
 > those using PostgreSQL. The patch provides case folding of string keys
 > during hash lookups. The need for this comes from ...

 > My question to the list is, can this functionality be added in a way that
 > doesn't adversely effect developers who won't use it, but helps us
 > PostgreSQL users and anyone else who might find it useful?  Judging from my
 > searches on the subject, it's not an uncommon impedance for PHP/PostgreSQL
 > users.

Oracle columns names are similarly case insensitive - unless the table
was created with quoted column names.  Users can see similar issues.

I think a PHP solution is more likely to need to be handled the way
PDO does, see PDO::CASE_xxxx.  However, what about creating an RFC on
the wiki to share what you have done and found.  Do you have any
benchmarks?

Chris

-- 
Christopher Jones, Oracle
Email: christopher.jones@oracle.com    Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/   Free PHP Book: http://tinyurl.com/f8jad

---

## #38302 — Dave Lee — 2008-06-16T22:16:04+00:00

URL: https://externals.io/message/38289#38302 · In reply to: #38295

On Mon, Jun 16, 2008 at 2:06 PM, Christopher Jones
<christopher.jones@oracle.com> wrote:
> Oracle columns names are similarly case insensitive - unless the table
> was created with quoted column names.  Users can see similar issues.

So same needs as as PostgreSQL.

> However, what about creating an RFC on
> the wiki to share what you have done and found.  Do you have any
> benchmarks?

I haven't benchmarked. I haven't looked, maybe you could tell me, are
there standard PHP benchmarks? If not I'll run some basic ones and
post the results here.

I'm new to the php-dev scene, I'll take a look at the wiki and other
RFCs posted.

thanks,
Dave

---

## #38305 — Christopher Jones — 2008-06-17T01:08:04+00:00

URL: https://externals.io/message/38289#38305 · In reply to: #38302

Dave Lee wrote:

> I haven't benchmarked. I haven't looked, maybe you could tell me, are
> there standard PHP benchmarks? If not I'll run some basic ones and
> post the results here.

Try the basic test Zend/benchmark.php.
Ideally, you'd create some specific tests that stress the changed code.

> I'm new to the php-dev scene, I'll take a look at the wiki and other
> RFCs posted.

The RFC page is at http://wiki.php.net/rfc

Chris

-- 
Christopher Jones, Oracle
Email: christopher.jones@oracle.com    Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/   Free PHP Book: http://tinyurl.com/f8jad
