Fab*_*oni 10 postgresql prepared-statement php array
我正在尝试从 PHP 准备一个查询,例如:
pg_prepare($con, "prep", "select * from test where tid in ($1)");
Run Code Online (Sandbox Code Playgroud)
然后执行它:
$strpar = "3,4,6,8,10";
pg_execute($con, "prep", array($strpars));
Run Code Online (Sandbox Code Playgroud)
问题是我无法传递一系列构建为 prepare 期望固定数量参数的值。有没有办法使参数动态?
Dan*_*ité 15
使用数组来表示一系列值:
pg_prepare($con, "prep", "select * from test where tid=ANY($1::int[])");
$strpar = "{3,4,6,8,10}";
pg_execute($con, "prep", array($strpars));
Run Code Online (Sandbox Code Playgroud)
演员要int[]
查询甚至可能是多余的,如果规划者能够通过自身来推断类型。
归档时间: |
|
查看次数: |
5424 次 |
最近记录: |