Forum und email

ora_bind

(PHP 4, PHP 5 <= 5.0.5)

ora_bind — 绑定一个 PHP 变量到一个 Oracle 参数

描述

bool ora_bind ( resource $cursor , string $PHP_variable_name , string $SQL_parameter_name , int $length [, int $type ] )

该函数将一个 PHP 变量与一个 SQL 参数绑定。 SQL 参数必须使用 ":name" 的形式。在该函数可选的 type 参数中,可以定义 SQL 参数类型。SQL 参数的类型是输入/输出 (0,默认)、输入(1) 、输出 (2) 中的一种。从 PHP 3.0.1 开始,可以使用常量 ORA_BIND_INOUT,ORA_BIND_IN 和 ORA_BIND_OUT 代替数字。

如果成功则返回 TRUE,失败则返回 FALSE。错误的细节能够使用 ora_error()ora_errorcode() 函数取得。

ora_bind() 必须在 ora_parse() 之后和 ora_exec() 之前调用。输入值由绑定的 PHP 变量指派。在调用 ora_exec() 函数之后,如果绑定的 PHP 变量有值输出,则 PHP 变量将等于该值。

Example#1 ora_bind() 函数范例

<?php
ora_parse
($curs"declare tmp INTEGER; begin tmp := :in; :out := tmp; :x := 7.77; end;");
ora_bind($curs"result"":x"$len2);
ora_bind($curs"input"":in"51);
ora_bind($curs"output"":out"52);
$input 765;
ora_exec($curs);
echo 
"Result: $result<br />Out: $output<br />In: $input";
?>