简体   繁体   English

如何通过全文搜索允许多列搜索

[英]how to allow mutilple column search with fulltext search

i'm trying to implement a fulltext search for my website and my problems is that the match() syntax is not allowing use of multiple columns. 我正在尝试为我的网站实现全文搜索,我的问题是match()语法不允许使用多个列。 can anyone help? 有人可以帮忙吗?

here is the code: 这是代码:

//
$sql = "SELECT * FROM tenders 
    INNER JOIN categories ON categories.category_id=tenders.category_id 
    INNER JOIN provinces ON provinces.province_id=tenders.province_id 
    WHERE MATCH (details,category, province) 
        AGAINST('$searchterm' IN NATURAL LANGUAGE MODE)";

$search_count = $db->query($search_sql);

//amount displayed per page
$per_page = 1;
//number of pages
$pages = ceil($search_count->num_rows/$per_page);

in the browser, i'm getting an error: 在浏览器中,我收到一个错误:

Notice: Trying to get property of non-object in C:\\xampp\\htdocs\\dailytenders\\search.php on line 39 注意:尝试在第39行的C:\\ xampp \\ htdocs \\ dailytenders \\ search.php中获取非对象的属性

how can i solve this. 我怎么能解决这个问题。 i have altered tables to engine=MyISAM and FULLTEXT on details, category and province columns. 我在详细信息,类别和省列上将表更改为engine=MyISAMFULLTEXT

In your code you have this: 在您的代码中,您有以下内容:

$search_count = $db->query($search_sql);

i think that must be this instead: 我认为那一定是这样的:

$search_count = $db->query($sql);

I used in past the MATCH function against multiple columns and worked good. 我过去将MATCH函数用于多列,并且运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM