PDO绑定MATCH AGAINST FULL TEXT搜索的值

时间:2013-09-15 13:01:11

标签: php pdo

$query=SELECT * FROM DB WHERE MATCH (email, name, live) 
AGAINST (:search IN BOOLEAN MODE) LIMIT :start, 20";
//:start is row count from previous query

$SQL=$db->prepare($query);                          
$SQL->bindValue(':search', '+'.$search.'*', PDO::PARAM_STR);

嗨,我是PHP PDO的新手,我有一个全文搜索查询使用PDO

这样绑定值是否正确,我将{strong> + 和 * 置于bindValue();

1 个答案:

答案 0 :(得分:3)

SELECT * FROM DB WHERE MATCH (email, name, live) 
AGAINST ('+searchword1 +searchword2*' IN BOOLEAN MODE)

会变成类似的东西:

SELECT * FROM DB WHERE MATCH (email, name, live) 
AGAINST (:search IN BOOLEAN MODE)

$value = '+searchword1 +searchword2*';

$SQL = $db->prepare($query);                          
$SQL->bindValue(':search', $value, PDO::PARAM_STR);