dongshang6790 2015-11-06 19:27
浏览 64
已采纳

如何在PDO中使用to_tsquery(postgres)?

I try to use full text search like

$STM = $PDO->prepare('SELECT title FROM zz_ad.advs WHERE to_tsvector(title) @@ to_tsquery(:str)');
$STM->execute(['str' => 'Hi!']);
$STM->fetchAll();

As a result i have: ERROR: syntax error in tsquery: "Hi!"

If i try without a "!" its work!

  • 写回答

1条回答 默认 最新

  • drkwpgrdb092239314 2015-11-06 19:44
    关注

    For the documentation:

    A tsquery value stores lexemes that are to be searched for, and combines them honoring the Boolean operators & (AND), | (OR), and ! (NOT). Parentheses can be used to enforce grouping of the operators.

    'Hi!' is not a valid lexeme. 'Hi' is.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?