Case sensitivity when searching for and displaying data

From: Lynna Landstreet <lynna(at)gallery44(dot)org>
To: <pgsql-php(at)postgresql(dot)org>
Subject: Case sensitivity when searching for and displaying data
Date: 2003-09-03 22:31:45
Message-ID: BB7BE411.AB4%lynna@gallery44.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hello,

I've gotten a simple PHP search page working on the artists database that
I've been developing these past few months, but I'm running into a few
problems with PostgreSQL's case sensitivity.

Ideally I'd like the search text to case insensitive, so that if the user
enters "jane smith", "Jane Smith" or "JANE SMITH", they'll still find the
record for Jane Smith. But I'm not sure how to do that.

I know that in PHP you can use strtoupper() and strtolower() to change the
case of text, but any solution I can think of with forcibly changing the
case of the search text the user inputs would be problematic given that I
don't necessarily know what case the names are in in the actual database -
most of them would be in standard title case, with the first character
capitalized and the rest lower case, but these are artists we're talking
about, so some of them insist on having their name in all lower case and
that sort of thing. Plus some artists from other cultures have
capitalization in their name that doesn't follow the English standard (de
Broin, di Maria, etc.). So I think I need a way of making the actual SQL
query case-insensitive, and I'm not sure how or even if that can be done.

Secondly, the case sensitivity thing is also messing up the order of the
displayed results. Right now I have them set to order by lastname, and that
makes any names that begin with a lower case character come at the end of
the list because of the order of the ASCII values of the letters, rather
than where they would normally be in alphabetical order. Does anyone know if
there's a way around this?

Thanks,

Lynna
--
Resource Centre Database Coordinator
Gallery 44
www.gallery44.org

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Rod Taylor 2003-09-03 23:18:04 Re: Case sensitivity when searching for and displaying data
Previous Message Robby Russell 2003-09-03 18:00:40 Re: pg_connect problem