F
F
furyon2015-11-06 21:33:07
PHP
furyon, 2015-11-06 21:33:07

How to use to_tsquery (postgres) with PDO?

Hello!
Writing:

$STM = $PDO->prepare('SELECT title FROM zz_ad.advs WHERE (to_tsvector(\'russian\',title) @@ to_tsquery(\'russian\', :str))');
$STM->execute(['str' => 'Привет!']);
$STM->fetchAll();

And I get an error
Syntax error: 7 ERROR: syntax error in tsquery: "Hi!"

If you write without an exclamation mark just "Hello" then there is no error. Which is very suspicious, like it's not even trying to escape anything.
What could be the problem?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
neeil, 2015-11-06
@neeil

or
SELECT title
FROM table
WHERE title_tsv @@ to_tsquery('zend') and
title_tsv @@ to_tsquery('fram:*')

V
Vladimir, 2015-11-07
@rostel

can @@ be replaced by \@\@?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question