Reputation: 406
Following problem: If I add in the query after MATCH
only text
or only title
, the query works fine and I get a array with the values. But when I added after MATCH the two rows title
and text
like that MATCH (title, text) the query wont works and I get Undefined variable: result
. I cant find the problem by myself and I think its the right syntax.
My error:
SQLSTATE[HY000]: General error: 1191 Can't find FULLTEXT index matching the column list
Both title and text have FULLTEXT index how I written above...
$keywordsonetoeight = implode(',', $keywordse[0]);
try {
$dbh = new PDO("mysql:host=$hostname;dbname=loginsystem",$user,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //
$sql = "SELECT id, autorid, autor, title, text, time
FROM posts
WHERE MATCH (title, text) AGAINST ('$keywordsonetoeight')
ORDER BY id DESC";
if ($res = $dbh->query($sql)) {// need to add this line in your code
// then after fetchColumn
$result = $res->fetchAll();
}
Upvotes: 0
Views: 128
Reputation: 34231
The error message indicates that you do not have the appropriate fulltext index. Probably you indexed title and text columns individually, but now you are trying to do a fulltext search on both of them, which requires a combined fulltext index.
I would add FULLTEXT (title,text)
index to your table and then you can do a MATCH (title, text) AGAINST ('$keywordsonetoeight')
Upvotes: 1