Hello all! I have tried to implement a simple search engine for my application. This is what I have done:
CREATE FULLTEXT INDEX item_name_other_name_desc_index
ON item (name,other_name,description)
public static function Search($string)
{
$delims = ',.; ';
$word = strtok($string,$delims);
while($word)
{
$result['accepted'][] = $word;
$word = strtok($delims);
}
$string = implode(" ", $result['accepted']);
$sql = 'SELECT item_id,name,other_name,description,price,discounted_price, thumbnail_photo,large_photo
FROM item
WHERE
MATCH(name,other_name,description)
AGAINST(:string)' ;
$parameters = array(':string' => $string);
$result['items'] = DB::GetAll($sql,$parameters);
return $result;
}
This works and searches for words only. Can anyone suggest me how can i improve it and how do i proceed if i want to search for strings like "Bi" which will show me results starting with that string.(for eg Bike..) Thanks!:)