Subject Re: php case insensitive field access
Author jackdmason
Thanks for your response. I apologize for not understanding the solution you proposed. I read the article referenced by Lester and now understand the proposal you both provided.
The databases we access are over 12 years old, and while we could rebuild them, that still skirts the issue.

InterBase 6 and all Firebird derivatives have been able to do case insensitive searches without having to add fields or special
collations. There is a query parameter that specifies the search is to be case insensitive.

This parameter is available for Delphi, C++, IBO_Objects, etc. but does not appear to be available via PHP. That is the issue. The option may actually be available via PHP but just undocumented since the PHP documentation is abysmally sparse.

The option should be available actually for the fetch (in addition to
IBASE_TEXT and IBASE_UNIXTIME) but since it is not documented, it is hard to know.

Who maintains the Firebird PHP interface? That is where this problem needs to be resolved with either better documentation or implementation of a missing Firebird capability.

MySQL performs a case-insensitive search when you use LIKE. Even if the PHP interface allowed that, it would solve the problem.


--- In firebird-php@yahoogroups.com, "slobtrot" wrote:
>
> 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
> > >
> >
>