Forums / General Questions / Case sensitive sreach

Case sensitive sreach

Results 1 to 5 of 5
28 Aug 2009, 16:14
#1
nidkolio avatar

nidkolio

New Zenner

Join Date:
May 2009
Posts:
55
Plugin Contributions:
0

Case sensitive sreach

Hi,
I notice that search is case sensitive. If in description of the products there is a word "Good" and i run a search for word "good", the search return zero results, but if i type "Good" the search results contains all products with this word.
How i can make this search to be not case sensitive?
Thank you in advance
01 Sep 2009, 16:03
#2
nidkolio avatar

nidkolio

New Zenner

Join Date:
May 2009
Posts:
55
Plugin Contributions:
0

Re: Case sensitive sreach

Any suggestions?
24 Oct 2009, 21:32
#3
largomike1 avatar

largomike1

New Zenner

Join Date:
Apr 2009
Posts:
25
Plugin Contributions:
0

Re: Case sensitive sreach

Hey there. I ran into the same problem. Did a little searching through the php files and found one that needed a few lines code altered. Here is the file and the location:

includes/modules/pages/advanced_search_result/header_php.php

Obviously, back up your file before making this change.

I changed mainly two things. First I convert the string of text entered by the user to lower case. Next I convert all of the database fields being searched to lower case. That's it. Here is a block of code where the changes are. It starts around line 292.

copy code from below here ====================

if (isset($keywords) && zen_not_null($keywords)) {
if (zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords)) {

$keywords = strtolower($keywords);

$where_str .= " AND (";
for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
switch ($search_keywords[$i]) {
case '(':
case ')':
case 'and':
case 'or':
$where_str .= " " . $search_keywords[$i] . " ";
break;
default:
$where_str .= "(lower(pd.products_name) LIKE '%:keywords%'
OR lower(p.products_model)
LIKE '%:keywords%'
OR lower(m.manufacturers_name)
LIKE '%:keywords%'";

$where_str = $db->bindVars($where_str, ':keywords', $search_keywords[$i], 'noquotestring');
// search meta tags
$where_str .= " OR (lower(mtpd.metatags_keywords)
LIKE '%:keywords%'
AND mtpd.metatags_keywords !='')";

$where_str = $db->bindVars($where_str, ':keywords', $search_keywords[$i], 'noquotestring');

$where_str .= " OR (lower(mtpd.metatags_description)
LIKE '%:keywords%'
AND mtpd.metatags_description !='')";

copy code from above here ========================


Hope that helps. I'm glad I could finally make a contribution. This forum has helped me many times.

- Michael Stein
24 Oct 2009, 21:57
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Case sensitive sreach

Remember that strtolower() is only reliable with latin language encoding. It does not work with multibyte language charactersets.
21 Feb 2011, 13:59
#5
gillgreen avatar

gillgreen

New Zenner

Join Date:
Feb 2011
Posts:
1
Plugin Contributions:
0

Re: Case sensitive sreach

DrByte:

Remember that strtolower() is only reliable with latin language encoding. It does not work with multibyte language charactersets.


Then what should I do if I have the same problem but with unicode characters? Actually, the problem is not quite the same: my search is working fine (it is not case-sensitive) with simple characters, but the special Hungarian vowels seem to be case-sensitive.

E.g. both pir and Pir work for piros but
űrk does not work for Űrkutatás

I'm using v1.3.9h, and I just can't figure this out..

Any suggestions?

Thanks in advance!