使用PHP搜索空字符串时出现PostgreSQL错误
此代码在PGAdmin上输出预期结果使用PHP搜索空字符串时出现PostgreSQL错误,php,postgresql,Php,Postgresql,此代码在PGAdmin上输出预期结果 select * from reports where manifesto_id = ' ' order by report_id 但是当我使用PHP pg_query_参数运行它时,就像这样 pg_query_params($connection,'select * from reports where manifesto_id = $1 order by report_id',array(' ')); 我得到了错误 PHP分析错误:语法错误,意外的“
select * from reports where manifesto_id = ' ' order by report_id
但是当我使用PHP pg_query_参数运行它时,就像这样
pg_query_params($connection,'select * from reports where manifesto_id = $1 order by report_id',array(' '));
我得到了错误
PHP分析错误:语法错误,意外的“按报表id排序”(T_常量\u封装的\u字符串),应为“,”或“,”
我曾尝试使用manifesto_id为Null的位置,但显然
' ' != Null
所以我没有得到想要的结果。有什么帮助吗?请尝试在查询中使用双引号。。我认为它实际上是在输入
”
,这破坏了您的查询。我认为它破坏了查询,因为您在单引号中使用了单引号”
,请尝试将查询字符串更改为“从报告中选择*,其中manifesto\u id=$1 order by report\u id”
为什么ID是长度为1的空字符串?它应该是“
”吗?在这种情况下,您可以尝试where char_length(manifesto_id)=0
如果不使用参数怎么办?如果您只是检查“”我真的看不出使用参数的原因,它不是基于用户的,谢谢lot@brianforan