case 'exact':
$text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
$filters[] = "a.product_name LIKE ".$text;
$filters[] = "a.product_description LIKE ".$text;
$filters[] = "a.product_code LIKE ".$text;
if($multi){
$filters2[] = "b.value LIKE ".$text;
}
break;
case 'all':
case 'any':
default:
$words = explode( ' ', $text );
$wordFilters = array();
$subWordFilters1 = array();
$subWordFilters2 = array();
$subWordFilters3 = array();
$wordFilters2 = array();
foreach ($words as $word) {
$word = $db->Quote( '%'.$db->getEscaped( $word, true ).'%', false );
$subWordFilters1[] = "a.product_name LIKE ".$word;
$subWordFilters2[] = "a.product_description LIKE ".$word;
$subWordFilters3[] = "a.product_code LIKE ".$word;
if($multi){
$wordFilters2[] = "b.value LIKE ".$word;
}
}
$wordFilters[0]= '(' .implode( ($phrase == 'all' ? ') AND (' : ') OR ('),$subWordFilters1). ')';
$wordFilters[1]= '(' .implode( ($phrase == 'all' ? ') AND (' : ') OR ('),$subWordFilters2). ')';
$wordFilters[2]= '(' .implode( ($phrase == 'all' ? ') AND (' : ') OR ('),$subWordFilters3). ')';
$filters[] = '(' . implode( ') OR (', $wordFilters ) . ')';
if($multi){
$filters2[] = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wordFilters2 ) . ')';
}
break;