简体   繁体   中英

PostgreSql PHP query #1: SQLSTATE[42601]: Syntax error:

I try to realize search from album where I set artist in form. I get variable from form and I make query. Successfully I get variable from the form.

$words = $_REQUEST['SQLfield'];
$tempquery =  "SELECT * FROM album WHERE to_tsvector(artist) @@ to_tsquery('$words')";
do_sql($tempquery);

When I search for example Jimi Hendrix the result is:

query #1: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error in tsquery: "Jimi Hendrix "

我没有使用PostgreSQL中,但之后快速扫描全文搜索的文档 ,我认为你应该使用plainto_tsquery函数,而不是to_tsquery ,因为to_tsquery预计类似'jimi & hendrix'plainto_tsquery将接受类似的短语, 'Jimi Hendrix'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM