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"; ?>
整理: 夕垌菪姬 (天地JPLOP)
|