由于本函數(shù)庫(kù)都是調(diào)用 Oracle8 Call-Interface (OCI8) 來存取 Oracle 數(shù)據(jù)庫(kù),因此在裝設(shè) Oracle 8 Client 的 Web 服務(wù)器上,可用本函數(shù)庫(kù)存取 Oracle 7.x 或 8.x 二種版本的數(shù)據(jù)庫(kù)服務(wù)器。                                                                                                                                                 
                OCIDefineByName: 讓 SELECT 指令可使用 php 變量。 
                OCIBindByName: 讓動(dòng)態(tài) SQL 可使用 PHP 變量。 
                OCILogon: 打開與 Oracle 的鏈接。 
                OCILogOff: 關(guān)閉與 Oracle 的鏈接。 
                OCIExecute: 執(zhí)行 Oracle 的指令部分。 
                OCICommit: 將 Oracle 的交易處理付諸實(shí)行。 
                OCIRollback: 撤消當(dāng)前交易。 
                OCINumRows: 取得受影響字段的數(shù)目。 
                OCIResult: 從目前列 (row) 的資料取得一欄 (column)。 
                OCIFetch: 取得返回資料的一列 (row)。 
                OCIFetchInto: 取回 Oracle 資料放入數(shù)組。 
                OCIColumnIsNULL: 測(cè)試返回行是否為空的。 
                OCIColumnSize: 取得字段類型的大小。 
                OCINewDescriptor: 初始新的 LOB/FILE 描述。 
                OCIParse: 分析 SQL 語(yǔ)法。                            OCIDefineByName
                讓 SELECT 指令可使用 PHP 變量。
                語(yǔ)法: boolean OCIDefineByName(int stmt, string ColumnName, mixed &variable, int [type]);
                返回值: 布爾值
                函數(shù)種類: 數(shù)據(jù)庫(kù)功能
                內(nèi)容說明: 本函數(shù)用來定義指定的 PHP 變量,使其能供 SQL 指令中的 SELECT 指令使用。在大小寫的問題上要注重一下,因?yàn)?Oracle 數(shù)據(jù)庫(kù)中的字段名稱其實(shí)都是大寫的名字。參數(shù) stmt 是經(jīng)過 Oracle 解析 (OCIParse) 后的字符串指針。參數(shù) ColumnName 是 Oracle 資料表上的字段名稱。參數(shù) variable 前面一定要加 & 符號(hào),表 PHP 變量位址。參數(shù) type 通常省略。治募注重的是欲使用 Oracle 8 中特有的新資料類型 LOB/ROWID/BFILE 等時(shí),需要先執(zhí)行 OCINewDescriptor() 函數(shù)。執(zhí)行本函數(shù)成功則返回 true 值。
                使用范例 
                這個(gè)范例是 thies@digicol.de 所提出的
                <?php
                $conn = OCILogon("scott","tiger");
                $stmt = OCIParse($conn,"select empno, ename from emp");
                /* 使用 OCIDefineByName 要在執(zhí)行 OCIExecute 前 */
                OCIDefineByName($stmt,"EMPNO",&$empno);
                OCIDefineByName($stmt,"ENAME",&$ename);
                OCIExecute($stmt);
                while (OCIFetch($stmt)) {
echo "empno:".$empno."/n";
echo "ename:".$ename."/n";
}
OCIFreeStatement($stmt);
                         OCILogoff($conn);
?>              OCIBindByName
                讓動(dòng)態(tài) SQL 可使用 PHP 變量。
                語(yǔ)法: boolean OCIBindByName(int stmt, string ph_name, mixed &variable, int length, int [type]);
                返回值: 布爾值
                函數(shù)種類: 數(shù)據(jù)庫(kù)功能
                內(nèi)容說明: 本函數(shù)用來定義指定的 PHP 變量,使其能供動(dòng)態(tài)的 SQL 指令 (Oracle Placeholder) 使用。在大小寫的問題上要注重一下,因?yàn)?Oracle 數(shù)據(jù)庫(kù)中的字段名稱其實(shí)都是大寫的名字。參數(shù) stmt 是經(jīng)過 Oracle 解析 (OCIParse) 后的字符串指針。參數(shù) ph_name 即為欲供動(dòng)態(tài) SQL 指令所使用的變量。參數(shù) variable 前面一定要加 & 符號(hào),表 PHP 變量位址。參數(shù) length 為資料的長(zhǎng)度,若設(shè)為 -1 則使用指定的 variable 資料最大值。參數(shù) type 可省略,其值有 OCI_B_FILE (二進(jìn)位文件)、OCI_B_CFILE (文字文件)、OCI_B_CLOB (文字 LOB)、OCI_B_BLOB (位 LOB) 及 OCI_B_ROWID (ROWID) 等數(shù)種。治募注重的是欲使用 Oracle 8 中特有的新資料類型 LOB/ROWID/BFILE 等時(shí),需要先執(zhí)行 OCINewDescriptor() 函數(shù),同時(shí)必須要將 length 參數(shù)設(shè)成 -1。執(zhí)行本函數(shù)成功則返回 true 值。
                使用范例 
                這個(gè)范例是 thies@digicol.de 所提出的,它加入三筆資料到 emp 資料表中,并使用 ROWID 來更新資料。
              <?php
                $conn = OCILogon("scott", "tiger");
                $stmt = OCIParse($conn,"insert into emp (empno, ename) "."values (:empno,:ename) "."returning ROWID into :rid");
                $data = array(1111 => "Larry", 2222 => "Bill", 3333 => "Jim");
                $rowid = OCINewDescriptor($conn, OCI_D_ROWID);
                OCIBindByName($stmt, ":empno", &$empno, 32);
                OCIBindByName($stmt, ":ename", &$ename, 32);
                OCIBindByName($stmt, ":rid", &$rowid, -1, OCI_B_ROWID);
                $update = OCIParse($conn, "update emp set sal = :sal where ROWID = :rid");
                OCIBindByName($update, ":rid", &$rowid, -1, OCI_B_ROWID);
                OCIBindByName($update, ":sal", &$sal, 32);
                $sal = 10000;
                while (list($empno, $ename) = each($data)) {
  OCIExecute($stmt);
  OCIExecute($update);
  } 
  $rowid->free();
  OCIFreeStatement($update);
  OCIFreeStatement($stmt);
  $stmt = OCIParse($conn, "select * from emp where empno in (1111,2222,3333)");
  OCIExecute($stmt);
  while (OCIFetchInto($stmt, &$arr, OCI_ASSOC)) {
  var_dump($arr);
  }
  OCIFreeStatement($stmt);
  /* 刪除剛加在 emp 資料表中的三筆資料 */
  $stmt = OCIParse($conn, "delete from emp where empno in (1111,2222,3333)");
  OCIExecute($stmt);
  OCIFreeStatement($stmt);
  OCILogoff($conn);
  ?>              OCILogon
                打開與 Oracle 的鏈接。
                語(yǔ)法: int OCILogon(string username, string passWord, string [OCACLE_SID]);
                                         返回值: 整數(shù)
                函數(shù)種類: 數(shù)據(jù)庫(kù)功能
                內(nèi)容說明: 本函數(shù)使 PHP 與 Oracle 建立鏈接。參數(shù) username 與 password 分別為連接的帳號(hào)及密碼。參數(shù) OCACLE_SID 為數(shù)據(jù)庫(kù)名稱,可省略。返回值為連接的代碼。              OCILogOff
                關(guān)閉與 Oracle 的鏈接。
                語(yǔ)法: boolean OCILogOff(int connection);
                返回值: 布爾值
                函數(shù)種類: 數(shù)據(jù)庫(kù)功能
                內(nèi)容說明: 本函數(shù)使 PHP 與 Oracle 的鏈接結(jié)束。參數(shù) connection 為連上 Oracle 的連接代碼。返回值 true 表示成功,false 表示發(fā)生錯(cuò)誤。              OCIExecute
                執(zhí)行 Oracle 的指令部分。
                語(yǔ)法: boolean OCIExecute(int statement, int [mode]);
                返回值: 布爾值
                函數(shù)種類: 數(shù)據(jù)庫(kù)功能
                內(nèi)容說明: 本函數(shù)用來執(zhí)行指定的 Oracle 指令部分,執(zhí)行前必須先由 OCIParse() 解析過該部分的 SQL 語(yǔ)法。參數(shù) statement 為解析過的代碼。參數(shù) mode 可省略,其默認(rèn)值為 OCI_COMM99v_ON_SUCCESS。返回值 true 表示成功,false 表示發(fā)生錯(cuò)誤。              OCICommit
                將 Oracle 的交易處理付諸實(shí)行。
                語(yǔ)法: boolean OCICommit(int connection);
                返回值: 布爾值
                函數(shù)種類: 數(shù)據(jù)庫(kù)功能
                內(nèi)容說明: 本函數(shù)會(huì)將最近一次 commit/rollback 后的交易 (transaction) 做永久性的修改。參數(shù) connection 為連上 Oracle 的連接代碼。返回值 true 表示成功,false 表示發(fā)生錯(cuò)誤。              OCIRollback
                撤消當(dāng)前交易。
                語(yǔ)法: boolean OCIRollback(int connection);
                返回值: 布爾值
                函數(shù)種類: 數(shù)據(jù)庫(kù)功能
                內(nèi)容說明: 本函數(shù)取消 Oracle 交易處理 (transaction) 對(duì)數(shù)據(jù)庫(kù)所做的修改