本文介绍了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参数化查询-重用命名的占位符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!