PDO Parameterized Query - Reuse named placeholders?(PDO 参数化查询 - 重用命名占位符?)
问题描述
本质上,我有一个值,我必须在我的 SQL 查询中调用几次.因此,是否可以在语句中重用相同的命名占位符,例如SELECT :Param FROM Table WHERE Column = :Param
,然后简单的 bindValue(":Param"),并且有两个 :Params 的值?
In essence, I have a value that I have to call a couple times in my SQL query. Thus, is it possible to reuse the same named placeholder in the statement e.g.
SELECT :Param FROM Table WHERE Column = :Param
, then simply bindValue(":Param"), and have the value be there for both :Params?
推荐答案
PDO::prepare 指出您不能在准备好的语句中两次使用同名的命名参数标记",所以我想那是不行的.
PDO::prepare states that "you cannot use a named parameter marker of the same name twice in a prepared statement", so I guess that's a no then.
这篇关于PDO 参数化查询 - 重用命名占位符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PDO 参数化查询 - 重用命名占位符?
基础教程推荐
- 使用 PDO 转义列名 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01