PHP3中使用ORACLE函數的使用說明
2024-08-29 13:32:29
供稿:網友
(作者:星空浪子 [email protected])
ocidefinebyname
讓 select 指令可使用 php 變數。
語法: boolean ocidefinebyname(int stmt, string columnname, mixed &variable, int [type]);
傳回值: 布林值
函式種類: 資料庫功能
內容說明
本函式用來定義指定的 php 變數,使其能供 sql 指令中的 select 指令使用。在大小寫的問題上要注意一下,因為 oracle 資料庫中的欄位名稱其實都是大寫的名字。參數 stmt 是經過 oracle 解析 (ociparse) 后的字串指標。參數 columnname 是 oracle 資料表上的欄位名稱。參數 variable 前面一定要加 & 符號,表 php 變數位址。參數 type 通常省略。值得注意的是欲使用 oracle 8 中特有的新資料型態 lob/rowid/bfile 等時,需要先執行 ocinewdescriptor() 函式。執行本函式成功則傳回 true 值。
ocibindbyname
讓動態 sql 可使用 php 變數。
語法: boolean ocibindbyname(int stmt, string ph_name, mixed &variable, int length, int [type]);
傳回值: 布林值
函式種類: 資料庫功能
內容說明
本函式用來定義指定的 php 變數,使其能供動態的 sql 指令 (oracle placeholder) 使用。在大小寫的問題上要注意一下,因為 oracle 資料庫中的欄位名稱其實都是大寫的名字。參數 stmt 是經過 oracle 解析 (ociparse) 后的字串指標。參數 ph_name 即為欲供動態 sql 指令所使用的變數。參數 variable 前面一定要加 & 符號,表 php 變數位址。參數 length 為資料的長度,若設為 -1 則使用指定的 variable 資料最大值。參數 type 可省略,其值有 oci_b_file (二進位檔)、oci_b_cfile (文字檔)、oci_b_clob (文字 lob)、oci_b_blob (位元 lob) 及 oci_b_rowid (rowid) 等數種。值得注意的是欲使用 oracle 8 中特有的新資料型態 lob/rowid/bfile 等時,需要先執行 ocinewdescriptor() 函式,同時必須要將 length 參數設成 -1。執行本函式成功則傳回 true 值。
ocilogon
開啟與 oracle 的連結。
語法: int ocilogon(string username, string password, string [ocacle_sid]);
傳回值: 整數
函式種類: 資料庫功能
內容說明
本函式使 php 與 oracle 建立連結。參數 username 與 password 分別為連線的帳號及密碼。參數 ocacle_sid 為資料庫名稱,可省略。傳回值為連線的代碼。
ocilogoff
關閉與 oracle 的連結。
語法: boolean ocilogoff(int connection);
傳回值: 布林值
函式種類: 資料庫功能
內容說明
本函式使 php 與 oracle 的連結結束。參數 connection 為連上 oracle 的連線代碼。傳回值 true 表示成功,false 表示發生錯誤。
ociexecute
執行 oracle 的指令區段。
語法: boolean ociexecute(int statement, int [mode]);
傳回值: 布林值
函式種類: 資料庫功能
內容說明
本函式用來執行指定的 oracle 指令區段,執行前必須先由 ociparse() 剖析過該區段的 sql 語法。參數 statement 為剖析過的代碼。參數 mode 可省略,其內定值為 oci_commit_on_success。傳回值 true 表示成功,false 表示發生錯誤。
ocicommit
將 oracle 的交易處理付諸實行。
語法: boolean ocicommit(int connection);
傳回值: 布林值
函式種類: 資料庫功能
內容說明
本函式會將最近一次 commit/rollback 后的交易 (transaction) 做永久性的修改。參數 connection 為連上 oracle 的連線代碼。傳回值 true 表示成功,false 表示發生錯誤。
ocirollback
撤消當前交易。
語法: boolean ocirollback(int connection);
傳回值: 布林值
函式種類: 資料庫功能
內容說明
本函式取消 oracle 交易處理 (transaction) 對資料庫所做的修改。參數 connection 為連上 oracle 的連線代碼。若成功則傳回 true,反之傳回 false。
ocinumrows
取得受影響欄位的數目。
語法: int ocinumrows(int statement);
傳回值: 整數
函式種類: 資料庫功能
內容說明
本函式傳回受 update 等指令影響的欄位 (column) 數目,若使用 select 等 sql 指令則不會有影響。參數 statement 為剖析過的代碼。
ociresult
從目前列 (row) 的資料取得一欄 (column)。
語法: string ociresult(int statement, mixed column);
傳回值: 字串
函式種類: 資料庫功能
內容說明
本函式傳回傳回一欄資料。參數 statement 為剖析過的代碼。參數 column 為欄位名。若使用新的資料形態 (rowids、lobs 與 files) 傳回亦均為字串。
ocifetch
取得傳回資料的一列 (row)。
語法: int ocifetch(int statement);
傳回值: 整數
函式種類: 資料庫功能
內容說明
本函式用來取得一列非空的資料。參數 statement 為剖析過的代碼。傳回值 true 表示成功取回一列,false 表示本列是空的或發生其它錯誤。
ocifetchinto
取回 oracle 資料放入陣列。
語法: int ocifetchinto(array &result, int [mode]);
傳回值: 整數
函式種類: 資料庫功能
內容說明
本函式將對 oracle 取回的資料放入陣列 result 中。傳回每列的欄位數目,若失敗則傳回 false。參數 mode 可省略,內定值為 oci_num,其它還有 oci_assoc、oci_return_nulls 及 oci_return_lobs 等。
ocicolumnisnull
測試傳回行是否為空的。
語法: boolean ocicolumnisnull(int stmt, mixed column);
傳回值: 布林值
函式種類: 資料庫功能
內容說明
本函式用來測試傳回的行 (column) 是否為空值 (null)。傳回 true 表示為空值。
ocicolumnsize
取得欄位型態的大小。
語法: int ocicolumnsize(int stmt, mixed column);
傳回值: 整數
函式種類: 資料庫功能
內容說明
本函式可以取得欄位 (column) 型態 (type) 的大小。
ocinewdescriptor
初始新的 lob/file 描述。
語法: string ocinewdescriptor(int connection , int [type]);
傳回值: 字串
函式種類: 資料庫功能
內容說明
本函式用來初始化新的 lob/file 描述值。
ociparse
分析 sql 語法。
語法: int ociparse(int connection, string query);
傳回值: 整數
函式種類: 資料庫功能
內容說明
本函式可用來分析 sql 語法或是 pl/sql 區段是否有錯誤。參數 connection 為連線代碼。參數 query 為 sql 指令字串。
本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。