Php postgresql to_tsquery()与PDO';s编写的声明
如果直接写Php postgresql to_tsquery()与PDO';s编写的声明,php,postgresql,pdo,Php,Postgresql,Pdo,如果直接写 $sql = "... to_tsquery( 'word_1 | word_2' )"; 工作正常,但如何将此语法用于PDO的准备语句 什么是正确的语法: $sql = " ... to_tsquery( :word_1 | :word_2 ) "; //this is incorrect $sth = $db->prepare( $sql ); $sth->execute( array( ':word_1'=>"word_1", ':word_2'
$sql = "... to_tsquery( 'word_1 | word_2' )";
工作正常,但如何将此语法用于PDO的准备语句
什么是正确的语法:
$sql = " ... to_tsquery( :word_1 | :word_2 ) "; //this is incorrect
$sth = $db->prepare( $sql );
$sth->execute(
array( ':word_1'=>"word_1", ':word_2'=>"word_2" )
);
像这样:
denis=# select to_tsquery('(foo | bar) & baz');
to_tsquery
---------------------------
( 'foo' | 'bar' ) & 'baz'
(1 row)
denis=# select (to_tsquery('foo') || to_tsquery('bar')) && to_tsquery('baz');
?column?
---------------------------
( 'foo' | 'bar' ) & 'baz'
(1 row)
这是如何回答这个问题的?@shapeshifter:也许是通过强调所需的算术?例如,不是
to_tsquery(:word|1:word|2)
而是to_tsquery(:word|1)| to_tsquery(:word|2)
。。。