I havent been able to find the answer to this, maybe I have overlooked it, but this is a very simple question:
I have a search module for Joomla/Virtuemart and I have 1 problem with the search results generated by this module.
When I type this search word "mysearch" I want it to find all results with words that are part of the search query, e.g. title: "This is my search" or "What a nice search"
How do I accomplish this with MySQL?
This is my working code:
$ab = explode(' ', $keyword);
$ccc='';
$ccc2='';
foreach ($ab as $k)
{
if (!empty($k))
{
if($ccc==''){
$ccc.= " concat(product_name, customtitle) RLIKE '".$db->getEscaped($k)."' AND";
}
else{
$ccc.= " concat(product_name, customtitle) RLIKE '".$db->getEscaped($k)."' AND";
}
if($ccc2==''){
$ccc2.= " product_sku RLIKE '".$db->getEscaped($k)."' AND";
}
else{
$ccc2.= " product_sku RLIKE '".$db->getEscaped($k)."' AND";
}
}
else {
$ccc2.= " product_sku RLIKE '0' AND";
$ccc.= " concat(product_name, customtitle) RLIKE '0' AND";
}
}
$ccc = rtrim($ccc, "AND");
$ccc2 = rtrim($ccc2, "AND");
$q ="(SELECT p.virtuemart_product_id, l.product_name
from #__virtuemart_products p join
#__virtuemart_products_".VMLANG." l
on p.virtuemart_product_id = l.virtuemart_product_id
WHERE ".$ccc." AND
p.published = '1'
LIMIT 0,".$prods."
)
union (select p.virtuemart_product_id, l.product_name
from #__virtuemart_products p join
#__virtuemart_products_".VMLANG." l
on p.virtuemart_product_id = l.virtuemart_product_id
where ".$ccc2." and
p.published = '1'
LIMIT 0,".$prods.")";