Joomla/Virtuemart の製品検索モジュールの MySQL 検索クエリに取り組んでいます。実際に既存の MySQL クエリを MATCH / AGAINST の使用から RLIKE の使用に変更しようとしていますが、変更したクエリでエラーが発生します。
エラーのない MATCH / AGAINST を使用した元のクエリを次に示します。
$searchstring = " +search* +string* +test*";
$query ="SELECT p.virtuemart_product_id, l.product_name from #__virtuemart_products AS p, #__virtuemart_products_".VMLANG." AS l WHERE MATCH(product_name,customtitle) AGAINST ('".$searchstring."' IN BOOLEAN MODE) AND p.published = '1' AND p.virtuemart_product_id = l.virtuemart_product_id LIMIT 0,".$prods." union (select p.virtuemart_product_id, l.product_name from #__virtuemart_products AS p, #__virtuemart_products_".VMLANG." as l where MATCH(product_sku) AGAINST ('".$searchstring."' IN BOOLEAN MODE) and p.published = '1' and p.virtuemart_product_id = l.virtuemart_product_id LIMIT 0,".$prods.")";
RLIKE を使用して変更したクエリを次に示します。
$searchstring = "search|string|test";
$query ="SELECT p.virtuemart_product_id, l.product_name from #__virtuemart_products AS p, #__virtuemart_products_".VMLANG." AS l WHERE product_name,customtitle RLIKE '".$searchstring."' AND p.published = '1' AND p.virtuemart_product_id = l.virtuemart_product_id LIMIT 0,".$prods." union (select p.virtuemart_product_id, l.product_name from #__virtuemart_products AS p, #__virtuemart_products_".VMLANG." as l where product_sku RLIKE '".$searchstring."' and p.published = '1' and p.virtuemart_product_id = l.virtuemart_product_id LIMIT 0,".$prods.")";
RLIKE 検索クエリが機能しない理由について、私は考えがありません。ここで私が間違っていることを誰かが指摘してくれることを願っています..