本文介紹了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 參數化查詢 - 重用命名占位符?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!