我在oracle中定义了一个集合类型:
CREATE OR REPLACE TYPE "NUM_ARRAY" AS TABLE OF NUMBER(8,0)
和存储过程:
PROCEDURE choice ( name IN VARCHAR2, order IN NUM_ARRAY )
如何做绑定参数与pdo和php这样?: $stmt->bindParam(':order ',...);
Thx
我不知道你是否还在寻找这个问题的答案,但我会给你我的答案,以防其他人也有同样的问题。我在下面的链接找到了我的答案。
http://www.oracle.com/technetwork/articles/fuecks - sps - 095636. - html
下面是我创建的一个函数,用来向Oracle过程传递参数。我使用的过程没有返回任何结果,因此这个函数没有捕获任何东西。
public function bindVariablesToProcedure($var1, $var2, $var3)
{
$rtn = []; // initalize array
if($this->dbconnect)
{
/* schema is your database schema
BindVariable is your stored procedure */
$bindSql = 'BEGIN schema.BindVariable(:var1, :var2, :var3); END;';
/* The numbers for the fourth parameter are the character lengths
that are in my database. I found that without these numbers
the "oci_bind_by_name" function would error out. */
$bindRes = oci_parse($this->dbconnect, $bindSql);
oci_bind_by_name($bindRes, ':var1', $var1, 100);
oci_bind_by_name($bindRes, ':var2', $var2, 5);
oci_bind_by_name($bindRes, ':var3', $var3, 100);
if(oci_execute($bindRes))
{
$rtn['status'] = "success";
}
else
{
$e = oci_error($bindRes); // For oci_execute errors pass the statement handle
$rtn['bindErrorSql'] = $e['sqltext'];
$rtn['bindErrorCode'] = $e['code'];
$rtn['bindErrorMsg'] = $e['message'];
$rtn['status'] = "failed";
}
}
return $rtn;
}