And*_*dre 4 postgresql perl dbi
我正在使用Perl脚本,我想使用命名参数在Postgres数据库中执行查询.在DBI文件说,这不便于携带:
有些驱动程序还允许使用占位符,例如:name和:N(例如:1,:2,依此类推)除了?,但它们的使用不可移植
无论如何我还想那样做.有谁知道Postgres驱动程序是否实现了这一点?
而不是执行这样的查询:
$q = $pg->prepare($query);
$q->bind_param(1, "value");
$q->bind_param(2, "value");
$q->execute();
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情:
$q = $pg->prepare($query);
$q->bind_param("parameterX", "value");
$q->bind_param("parameterY", "value");
$q->execute();
Run Code Online (Sandbox Code Playgroud)
干杯!
编辑
正确的语法如下(我错过了冒号):
$q = $pg->prepare($query);
$q->bind_param(":parameterX", "value");
$q->bind_param(":parameterY", "value");
$q->execute();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2192 次 |
| 最近记录: |