我正在尝试使用以下查询在Joomla系统中进行全文搜索:
SELECT `id`,`user_id`,`article_id`,`body`,`created_time`
FROM `#__user_notes`
WHERE (`user_id` = '660' AND `article_id` IN (23, 24) AND `id` < '385')
OR (MATCH (body) AGAINST (`test`) AND `id` < '385' AND `user_id` = '660')
ORDER BY id DESC LIMIT 10
抛出此错误:
JDatabaseExceptionExecuting: Unknown column 'test' in 'where clause'
在没有全文搜索行的情况下工作正常:
OR (MATCH (body) AGAINST (`test`) AND `id` < '385' AND `user_id` = '660')
我已将ENGINE
设置为MYISAM
,因为此答案建议fulltext query in joomla
答案 0 :(得分:2)
您应该从查询中删除反引号。
OR (MATCH (body) AGAINST (`test`) AND `id` < '385' AND `user_id` = '660')
上方应替换为
OR (MATCH (body) AGAINST ('test') AND `id` < '385' AND `user_id` = '660')
Mysql使用反引号作为列名,但是test
是您要搜索的文本。
因为您正在使用Joomla,所以在Joomla中应该使用$db->quoteName
而不是$db->quote
。 quoteName
用于转义列名,quote
用于值