我正在为 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 搜索查询不起作用。我希望有人能指出我在这里做错了什么..