具有多个命名参数的PDO bindParam() [英] PDO bindParam() with multiple named parameters
本文介绍了具有多个命名参数的PDO bindParam()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PDO不能使用单个bindParam()将值绑定到查询中多次出现的参数吗?
我很惊讶,我认为这是可能的,但是我没有在网上找到关于php文档的任何信息.欢迎进行任何澄清/替代!
I'm surprised, I thought it was possible, but I didn't find any info on php's docs on this, neither on the web. Any clarification / alternative is welcome!
注意:我正在使用php 5.3.6/5.3.8(dev/prod)
考虑以下准备好的声明:
Consider this prepared statement :
INSERT INTO table VALUES (:param1, 0), (:param1, 1);
现在,如果我将值绑定到查询:
Now, if I bind values to my query:
bindParam(":param1",$my_param1);
我有PDO错误:
SQLSTATE [HY093]:无效的参数号
SQLSTATE[HY093]: Invalid parameter number
推荐答案
请参见 PDO ::准备
You cannot use a named parameter marker of the same name twice in a prepared statement
这篇关于具有多个命名参数的PDO bindParam()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文