简体   繁体   English

php + oracle(OCI)问题

[英]Problem with php+oracle(OCI)

Catchable fatal error: Object of class OCI-Collection could not be converted to string in E:\\php\\htdocs\\PHPRPC\\func.php on line 318 可捕获的致命错误:无法在第318行的E:\\ php \\ htdocs \\ PHPRPC \\ func.php中将类OCI-Collection的对象转换为字符串

The code: 编码:

$sql='BEGIN NCCM_INTERFACE_HISDETAIL(:orgcode,:inhiscode,:inputer,:items); END;';
$conn=oci_connect('chis','chis123','ORCL','UTF8');
$stmt = oci_parse($conn, $sql);
$collection = oci_new_collection($conn,"NCCM_INTERFACE_TABLE");
foreach ($items as $item)
{
    $collection->append($item);
}
oci_bind_by_name($stmt, ":orgcode", $orgcode, -1);
oci_bind_by_name($stmt, ":inhiscode", $inhiscode, -1);
oci_bind_by_name($stmt, ":inputer", $inputer, -1);
oci_bind_by_name($stmt, ":items", $collection,-1); //here the error line
$s=oci_execute($stmt);

Can anyone help me to sort out this issue? 谁能帮我解决这个问题? Thanks in Advance. 提前致谢。

The issue is you are binding a collection object while Oracle expects the bound type to be SQLT_CHR , eg a VARCHAR . 问题是您要绑定集合对象,而Oracle希望绑定类型为SQLT_CHR ,例如VARCHAR Thus, Oracle will try to use the bound object in a string context, which is not possible because the collection apparently has no __toString method implemented. 因此,Oracle将尝试在字符串上下文中使用绑定的对象,这是不可能的,因为该集合显然没有实现__toString方法。 Hence you get the error that the object could not be converted to string. 因此,您会收到以下错误消息:对象无法转换为字符串。

I am not sure on this, but try to supply a different type in the binding call, for instance: 我对此不确定,但是请尝试在绑定调用中提供其他类型,例如:

oci_bind_by_name($stmt, ":items", $collection,-1, OCI_B_NTY);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM