Ora_Bind
链接 PHP 变量到 Oracle 参数。
语法: int ora_bind(int cursor, string PHP variable name, string SQL parameter name, int length, int [type]);
返回值: 整数
函数种类: 数据库功能
本函数将 PHP 变量与 SQL 参数系结在一起。SQL 参数 (SQL parameter) 必须是类似 ":name" 的型式。语法中的 type 为可省略的参数选项,可以设成下面三种数字之一:0 为默认值,表输入/输出 (in/out);1 表输入 (in);2 表输出 (out)。在 PHP 3.0.1 版之后,亦可以使用下列常量代替 type 的三种数字值:ORA_BIND_INOUT、ORA_BIND_IN 或 ORA_BIND_OUT。重要的是本函数应是在 ora_parse() 之后与 ora_exec() 之前呼叫使用。若成功则返回 true,反之返回 false。要处理详细的错误信息可使用 ora_error() 及 ora_errorcode()。
<?php ora_parse($curs, "declare tmp INTEGER; begin tmp := :in; :out := tmp; :x := 7.77; end;"); ora_bind($curs, "result", ":x", $len, 2); ora_bind($curs, "input", ":in", 5, 1); ora_bind($curs, "output", ":out", 5, 2); $input = 765; ora_exec($curs); echo "Result: $result<BR>Out: $output<BR>In: $input"; ?>
|