Kiyarash
Kiyarash

Reputation: 2578

Search mysql Database using MATCH() don't work

There is more than ten questions in stackoverflow about this topic and I read most of them but still I can't search my DB...!!!
This is my table's structur:

$sql = "CREATE TABLE content.htmlLink(
LessonID INT NOT NULL,
LessonTitle VARCHAR(512) NOT NULL COLLATE utf8_general_ci,
LessonContent TEXT NOT NULL COLLATE utf8_general_ci,
storeDate VARCHAR(32) NOT NULL COLLATE utf8_general_ci,
fileName VARCHAR(128) NOT NULL COLLATE utf8_general_ci,

FOREIGN KEY(LessonID) REFERENCES `content`.`html`(id)

);";

and parent table :

$sql = "CREATE TABLE content.html(
id INT(11) NOT NULL AUTO_INCREMENT,
title VARCHAR(512) NOT NULL COLLATE utf8_general_ci,
content TEXT NOT NULL COLLATE utf8_general_ci,
storeDate VARCHAR(32) NOT NULL COLLATE utf8_general_ci,
tag1 VARCHAR(32) NOT NULL COLLATE utf8_general_ci,
tag2 VARCHAR(32) COLLATE utf8_general_ci,
tag3 VARCHAR(32) COLLATE utf8_general_ci,
tag4 VARCHAR(32) COLLATE utf8_general_ci,
tag5 VARCHAR(32) COLLATE utf8_general_ci,
PRIMARY KEY(id)
);";

There is no problem with insert information to tables.
But, now I'm trying to made a search engine for users. I want to search if user pattern exist in LessonContent , so I wrote this lines:

$sql = "SELECT * FROM content.htmllink 
        WHERE MATCH(LessonTitle,LessonContent) AGAINST('$pattern')";
$query = $conn->query($sql);

//I tried to use bind param
$sql = "SELECT * FROM content.htmllink 
        WHERE MATCH(LessonTitle,LessonContent) AGAINST('?')";
$prepare = $conn->prepare($sql);
$prepare->execute( array( $pattern ) );
$fetch = $prepare->fetchAll();

//or with IN BOOLEAN MODE arg
$sql = "SELECT * FROM content.htmllink WHERE MATCH(LessonTitle,LessonContent) AGAINST('html', IN BOOLEAN MODE)";


Even I checked the Query with specific pattern like:

$sql = "SELECT * FROM content.htmllink 
        WHERE MATCH(LessonTitle,LessonContent) AGAINST('html')";

But still $query is false. Would you tell me where is my mistake? Thanks in advance. I searched this links:

http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html

Another site

http://dev.mysql.com/doc/refman/5.5/en/fulltext-query-expansion.html

How to search MySQL database using MATCH AGAINST method that returns only rows that have a particular field value?

How to make MYSQL search for minimum 3 keyword matches?

and so many others...

Upvotes: 0

Views: 130

Answers (1)

underscore
underscore

Reputation: 6887

InnoDb (Mysql Version 5.6) does support FULL TEXT SEARCHES.As you mentioned your version is bellow that it so it doesn't support

See the link here

Upvotes: 1

Related Questions