Subject Re: php case insensitive field access
Author slobtrot
Hi,

> You cannot just capitalize the first and last
>name and accomplish anything. "McGrath" would
>not be found, nor would "van Duran",

Actually you can, and yes McGrath and van Duran would be found.

When uppercasing both the variable you give to the search (From PHP) and the sql to encapsule in search in upper(). I am doing this in lots and lots of places, and it works exactly as expected. It does not matter how you mix uppercase/lowercase in the search variable, or wha mix of uppercase/lowercase you have stored the name with in the table.

When both the value you give the select, and the value the select reads from the table, are uppercased, it no longer matters what case was used when storing or what case is used when searching. In essence, it searches for 'MCGR' in finds all instances of 'MCGRATH' (regarless is stored as 'McGrAtH' or 'mcGrath' etc..)

- Aaron


--- In firebird-php@yahoogroups.com, "jackdmason" wrote:
>
> This solution will not work. Both InterBase and Firebird allow case insensitive searches, as does MySQL. The php interface should allow that option to be used as part of a query.
>
> You cannot just capitalize the first and last name and accomplish anything. "McGrath" would not be found, nor would "van Duran", "MacDougal", etc., nor can you catch instances where a name has been entered incorrectly, such as Mcgee, variant spellings, etc.
>
> At present we have to have our web server call a store server to process InterBase accesses because of this very reason; not only with names, but with book titles, authors (may or may not a name or company), etc.
>
> We just need the php interface, at least for Firebird, to be fixed so we can do case insensitive searches. Delphi can do it, C++ can do it. Why cannot php do it?
>
>
> --- In firebird-php@yahoogroups.com, Lester Caine wrote:
> >
> > slobtrot wrote:
> > > Here's an example:
> > >
> > > $sql = "SELECT * FROM CUST WHERE LASTNAME LIKE upper(?) AND FIRSTNAME LIKE upper(?)";
> > > $sth = ibase_query( $db_handle, $sql, strtoupper($search_var1), strtoupper($search_var2));
> > > if ($sth) {
> > > if ($row = ibase_fetch_object($sth)) {
> > > //$save_in_variable = $row->FIELDNAME;
> > > }
> > > }
> > > ibase_free_result($sth);
> > >
> > > --- Infirebird-php@yahoogroups.com, "jackdmason" wrote:
> > >> >
> > >> >Using the php interface is there a way to specify in the query the data fields are to be case insensitive such that a query such as:
> > >> >
> > >> >SELECT * FROM CUST WHERE LASTNAME LIKE 'mcg%' AND FIRSTNAME LIKE 'jo%'
> > >> >
> > >> >will find Josh Mcgee, josh McGee, Joe McGrath, john mcGregor, etc.?
> >
> > It is not unusual to create triggers for the firstname and lastname fields to
> > provide uc_fn and uc_ln which are then indexed also, so searching is a lot
> > faster. Taking it a step further for genealogical data, this field can be a
> > 'sound like' rather then a simple upper case. My own genealogical data actually
> > uses both fields ;)
> >
> > --
> > Lester Caine - G8HFL
> > -----------------------------
> > Contact - http://lsces.co.uk/wiki/?page=contact
> > L.S.Caine Electronic Services - http://lsces.co.uk
> > EnquirySolve - http://enquirysolve.com/
> > Model Engineers Digital Workshop - http://medw.co.uk
> > Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
> >
>