ora_bind

(PHP 3, PHP 4, PHP 5 <= 5.1.0RC1)

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 變量將等於該值。

例子 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";
?>