oci_bind_by_name:PHP致命错误:只能通过引用传递变量
问题描述:
I'm trying to call a function from an Oracle package and I'm getting this error:
PHP Fatal error: Only variables can be passed by reference
This is my code:
$connection = $this->getConnection();
if (!$connection){
return null;
}
$s = oci_parse($connection, "begin my_package.my_function(
:param1
); end;");
//getting the error in this following line:
oci_bind_by_name($s, ":param1", "13")
if($result = oci_execute($s)){
....
}
...
I've been looking at other posts with this exactly same error but none of them seem to be related with this issue.
I'm using PHP version 5.5.6 over IIS 7.5 in a Windows 7 machine.
This is the definition of the function at my pacakage:
FUNCTION my_function(param1 IN VARCHAR2) RETURN CLOB IS
BEGIN
-- etc...
-- etc...
END;
我正在尝试从Oracle包中调用函数,我收到此错误: p>
PHP致命错误:只能通过引用传递变量 p> blockquote>
这是我的代码: p> \ n
$ connection = $ this-> getConnection(); if if(!$ connection){ return null; } $ s = oci_parse($ 连接,“开始my_package.my_function( :param1 );结束;”); //在以下行中获取错误: oci_bind_by_name($ s,“:param1”,“13” ) if($ result = oci_execute($ s)){ .... } ... code> pre>
我一直在查看其他帖子,但这些错误完全相同,但似乎没有一个与此问题相关。 p>
我在Windows 7机器上使用PHP 5.5.6而不是IIS 7.5。 p>
这是我的pacakage中函数的定义 : p>
FUNCTION my_function(param1 IN VARCHAR2)RETURN CLOB is BEGIN -- etc ... -- etc ... END; 代码> pre> div>
答
Third parameter of oci_bind_by_name is passed by reference, hence you need to store it in a variable first:
$param1 = "13";
oci_bind_by_name($s, ":param1", $param1);