2
$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 的全文搜索查询

像这样绑定值是否正确,我把+*放在里面bindValue();

4

1 回答 1

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);
于 2013-11-27T10:02:55.200 回答