PHP link Oracle function

zhaozj2021-02-11  154

※ DB_LOGON () Open Database Connection ※ DB_Query () Universal Select ※ DB_Change () Database change Universal Function (Insert, Delete, Update) ※ DB_Insert () Insert, DB_Change () ※ DB_DELETE () DELETE, DB_Change ( ) ※ DB_UPDATE () Update, DB_CHANGE () DB_CHANGE () DB_COMMIT () Transaction Retreat ※ DB_ROLLBACK () Transaction Retreat ※ DB_LOGOFF () Disconnect Database Connection Class C_ORA_DB {Variable Definition VAR $ C_USER = ""; Database User Name VAR $ C_passwd = ""; Database Delivery VAR $ C_DB = ""; Database Name VAR $ I_LINKID = 0; Connection Handle VAR $ I_STMTID = 0; Query Handle VAR $ Color = ""; Global Color Function Name: DB_Logon () Role: Open Database Connection Parameters: None Return Value: Connection Handle (Integer) Note: No function db_logon () {$ this-> i_linkid = @ocilogon ($ this-> c_user, $ this-> c_passwd, $ this-> c_db ); if ($ this-> i_linkid == 0) {alertexit ('database link failed, please contact DBA!');} Return $ this-> i_linkid;} function name: db_query ($ c_sql, $ a_define = " ", $ I_START = -1, $ i_END = -1) Role: SELECT parameter: $ c_sql sql statement $ A_DEFINE The field that needs to be bound. Array type $ i_START Start Take Record -1 All Records $ I_END End Removing Record Return Value: Two-dimensional arrays ($ A_RS) Note: Value of the corresponding fields by numbers 0, 1, 2 .... Value of the corresponding field; Or by querying the field name, you can access the value of the corresponding field, such as by $ A_RS [0] or $ A_RS [0] ['Name'] or $ A_RS [0] ['Name'] can access the first record Name field $ i_start, $ i_end is a parameter that is used in conjunction with the paging.

Function DB_Query ($ C_SQL, $ A_DEFINE = ", $ i_START = -1, $ i_end = -1) {ifrtexit (" Parameter is not full! ");} Check parameter connection detection IF ($ THIS -> i_linkid == 0) {Alertexit ('Database link failed, please contact DBA!');} Format Detection $ this -> i_stmtid = ociparse ($ this -> i_linkid, $ c_sql); if (! $ This - > I_stmtid) {Alertexit ('sql format error! Please contact the programmer');} If you do not specify a binding field, get if IF ($ A_DEFINE == ") {$ A_CUR = EXPLode from the SQL statement ($ A_DEFINE ==") {$ A_CUR = EXPLODE "SELECT", $ c_sql); $ A_CUR = EXPLODE ("from", $ A_CUR [1]); $ A_DEFINE = EXPLODE (",", $ A_CUR [0]);} Binding Database Table field IF (GetType $ A_define) == "Array") Query columns are array {for ($ i = 0; $ I i_stmtid, "$ A_DEFINE_UP [$ I]", & $$ a_define [$ I]); Bind}} elseif (Trim ($ A_DEFINE) <> "" Query columns only one {$ A_DEFINE_UP = TRIM (STRTOUPPER ($ A_DEFINE)); OCIDEFINENAME ($ this -> i_stmtid, "$ A_DEFINE_UP ", & $$ a_define);} Perform a binding SQL statement if (! OCIEXECUTE ($ this -> i_stmtid) {echo" Perform error: SQL Error: $ c_sql
; return false; } $ loc = 0; return to the first dimension of the two-dimensional array to control the variable $ CNT = 0; start to extract the logo Record While (OCIFETCHINTO ($ this -> i_stmtid, & $ cur, oci_assoc) {Take the query out All records IF ($ i_start == -1) {if (GetType ($ A_DEFINE) == "Array") Query Column is an array {for ($ i = 0; $ I $$ a_define [$ I] = $ CUR [$ A_DEFINE_UP [$ I]];} $ A_RS [$ LOWER] [$ I] = $$ a_define [$ I];

Visit $ A_RS [$ Lower] [$ A_DEFINE [$ I]] = $$ A_DEFINE [$ I]] = $ A_DEFINE_UP [$ I]] = $$ A_DEfine [$ ]er] I]; use capital access}} elseif (Trim ($ a_define) <> "" "Query columns only one {IF ($ CUR [$ A_DEFINE_UP] <> $$ a_define) {$$ a_define = $ cur [$ a_define_up] } $ A_rs [$ limited] [$ A_RS [$ LOWER] [$ a_define] = $$ A_DEFINE; Use a lowercase to access $ A_RS [$ loc] [$ limited] [$ A_DEFINE_UP] = $$ A_Define; use some of these access} $ loc ; subscript plus one} Remove the specified record (with page use) IF ($ i_start <> -1) {IF ($ CNT> = $ i_START) {$ CNT ; IF ($ i_end) $ I_start <> 0) {$ i_END - == "Array" {for ($ I = 0; $ I $$ a_define [$ I] = $ CUR [$ A_DEFINE_UP [$ I]];} $ A_RS [$ Lower] [$ I] = $$ a_define [$ I]; Use Digital Access $ A_RS [$ LOWER] [$ A_DEFINE [$ I]] = $$ a_define [$ I]; Use some to access $ A_RS [$ Lower] [$ A_DEFINE_UP [$ I] = $$ a_define [$ I]; use capital access}} elseif (TRIM ($ A_DEFINE) <> "") {if ($ CUR [$ A_DEFINE_UP] <> $$ a_define) {$$ a_define = $ Cur [$ A_DEFINE_UP]; $ A_RS [$ LOWER] [0] = $$ a_define; access $ A_RS [$ loc] with a number [$ A_DEFINE] = $$ A_Define; Some visits $ A_RS [$ Lower_up] = $$ A_Define; use capital access} $ loc ;} else {Break; if $ i_end- $ i_start = 0 indicates the record and jump out the while loop}} else {$ CNT ; if $ CNT <$ i_START, $ CNT }}} While ends the handle and returns the query data (a two-dimensional array) OCIFREESTATEMENT ($ this -> i_stmtid); Return $ A_RS;} Function end function name: db_change ($ C_SQL, $ A_BIND) RE: DB Change Parameters: $ c_sql SQL Statement $ A_BIND The field that needs to be bound.

Array type return value: Boolean Note: INSERT, DELETE, UPDATE Universal Function DB_Change ($ C_SQL, $ A_BIND = ") {if (! $ C_sql) {alertexit (" Parameter is not full! ");} Check parameter connection detection IF ($ this -> i_linkid == "") {Alertexit ("Our database is busy, please contact it later!");} Format detection $ this -> i_stmtid = = ociparse ($ this -> i_linkid, $ c_sql) ; if (! $ this -> i_stmtid) {alertexit ('sql format error! Contact programmer');} Bind IF (GetType ($ A_BIND) == "Array") {for ($ I = 0; $ I i_stmtid, ": $ A_BIND [$ I]", & $$ A_bind [$ I], -1); Bind}} Elseif (TRIM ($ A_BIND) <> "" is not an array Yes, it is character {Global $$ a_bind; $$ a_bind = Stripslashes ($$ a_bind); $$ a_bind = STR_REPLACE (" I_stmtid, ": $ arrbind", & $$ a_bind, -1);} Perform and detect if it is successful if (! Ociexecute ($ this -> i_stmtid, oci_default)) {echo " Perform an error: SQL error: $ c_sql
"; return false;} / * Replies of affected rows Global $ I_CHANGENUM; $ I_CHANGENUM = OCINUMROWS ($ this -> i_stmtid); * / Release Handle, Passage OCIFREESTATEMENT ($ this -> i_stmtid); Return true;} function name: DB_DELETE ($ c_sql) Role: Delete Parameters: C_SQL SQL statement Return Value: Boolean Note: This function is just to use intuitive, intrinsically call db_change () Function DB_DELETE ($ c_sql) {Return $ this -> db_change ($ c_sql);} function name: db_insert ($ c_sql, a_bind ) The role: INSERT parameters:

C_SQL SQL Statement A_BIND Bind Return Value: Boolean Note: This function is just to use intuitive, intrinsically call db_change () Function DB_INSERT ($ c_sql, $ a_bind = ") {RETURN $ THIS -> DB_Change ($ c_sql, $ A_BIND) ); Function name: DB_UPDATE: Update Parameters: c_sql SQL Statement A_BIND Bind Return Value: Boolean Note: This function is just to use intuitive, intrinsically call DB_Change () Function DB_UPDATE ($ C_SQL, $ A_bind = "") {RETURN $ THIS -> DB_Change ($ c_sql, $ a_bind);} function name: db_commit () effect: Transaction submitting parameters: None return value: Boox Note: No function db_commit () {Return (ocicommit ($ this-> i_linkid));} function name: db_rollback () Role: Transaction Retreat: None Return Value: Boolean Note: No function db_rollback () {Return (Ocir Noback ($ this-> i_linkid);} Function Name: DB_LOGOFF () Role: Disconnect Database Connection Parameters: No Return Value: Boolean Note: No Function DB_Logoff () {Return (Ocilogoff ($ this-> i_linkid);}

※ DB_LOGON () Open Database Connection ※ DB_Query () Universal Select ※ DB_Change () Database change Universal Function (Insert, Delete, Update) ※ DB_Insert () Insert, DB_Change () ※ DB_DELETE () DELETE, DB_Change ( ) ※ DB_UPDATE () Update, DB_CHANGE () DB_CHANGE () DB_COMMIT () Transaction Retreat ※ DB_ROLLBACK () Transaction Retreat ※ DB_LOGOFF () Disconnect Database Connection Class C_ORA_DB {Variable Definition VAR $ C_USER = ""; Database User Name VAR $ C_passwd = ""; Database Delivery VAR $ C_DB = ""; Database Name VAR $ I_LINKID = 0; Connection Handle VAR $ I_STMTID = 0; Query Handle VAR $ Color = ""; Global Color Function Name: DB_Logon () Role: Open Database Connection Parameters: None Return Value: Connection Handle (Integer) Note: No function db_logon () {$ this-> i_linkid = @ocilogon ($ this-> c_user, $ this-> c_passwd, $ this-> c_db ); if ($ this-> i_linkid == 0) {alertexit ('database link failed, please contact DBA!');} Return $ this-> i_linkid;} function name: db_query ($ c_sql, $ a_define = " ", $ I_START = -1, $ i_END = -1) Role: SELECT parameter: $ c_sql sql statement $ A_DEFINE The field that needs to be bound. Array type $ i_START Start Take Record -1 All Records $ I_END End Removing Record Return Value: Two-dimensional arrays ($ A_RS) Note: Value of the corresponding fields by numbers 0, 1, 2 .... Value of the corresponding field; Or by querying the field name, you can access the value of the corresponding field, such as by $ A_RS [0] or $ A_RS [0] ['Name'] or $ A_RS [0] ['Name'] can access the first record Name field $ i_start, $ i_end is a parameter that is used in conjunction with the paging.

Function DB_Query ($ C_SQL, $ A_DEFINE = ", $ i_START = -1, $ i_end = -1) {ifrtexit (" Parameter is not full! ");} Check parameter connection detection IF ($ THIS -> i_linkid == 0) {Alertexit ('Database link failed, please contact DBA!');} Format Detection $ this -> i_stmtid = ociparse ($ this -> i_linkid, $ c_sql); if (! $ This - > I_stmtid) {Alertexit ('sql format error! Please contact the programmer');} If you do not specify a binding field, get if IF ($ A_DEFINE == ") {$ A_CUR = EXPLode from the SQL statement ($ A_DEFINE ==") {$ A_CUR = EXPLODE "SELECT", $ c_sql); $ A_CUR = EXPLODE ("from", $ A_CUR [1]); $ A_DEFINE = EXPLODE (",", $ A_CUR [0]);} Binding Database Table field IF (GetType $ A_define) == "Array") Query columns are array {for ($ i = 0; $ I i_stmtid, "$ A_DEFINE_UP [$ I]", & $$ a_define [$ I]); Bind}} elseif (Trim ($ A_DEFINE) <> "" Query columns only one {$ A_DEFINE_UP = TRIM (STRTOUPPER ($ A_DEFINE)); OCIDEFINENAME ($ this -> i_stmtid, "$ A_DEFINE_UP ", & $$ a_define);} Perform a binding SQL statement if (! OCIEXECUTE ($ this -> i_stmtid) {echo" Perform error: SQL Error: $ c_sql
; return false; } $ loc = 0; return to the first dimension of the two-dimensional array to control the variable $ CNT = 0; start to extract the logo Record While (OCIFETCHINTO ($ this -> i_stmtid, & $ cur, oci_assoc) {Take the query out All records IF ($ i_start == -1) {if (GetType ($ A_DEFINE) == "Array") Query Column is an array {for ($ i = 0; $ I $$ a_define [$ I] = $ CUR [$ A_DEFINE_UP [$ I]];} $ A_RS [$ LOWER] [$ I] = $$ a_define [$ I];

Visit $ A_RS [$ Lower] [$ A_DEFINE [$ I]] = $$ A_DEFINE [$ I]] = $ A_DEFINE_UP [$ I]] = $$ A_DEfine [$ ]er] I]; use capital access}} elseif (Trim ($ a_define) <> "" "Query columns only one {IF ($ CUR [$ A_DEFINE_UP] <> $$ a_define) {$$ a_define = $ cur [$ a_define_up] } $ A_rs [$ limited] [$ A_RS [$ LOWER] [$ a_define] = $$ A_DEFINE; Use a lowercase to access $ A_RS [$ loc] [$ limited] [$ A_DEFINE_UP] = $$ A_Define; use some of these access} $ loc ; subscript plus one} Remove the specified record (with page use) IF ($ i_start <> -1) {IF ($ CNT> = $ i_START) {$ CNT ; IF ($ i_end) $ I_start <> 0) {$ i_END - == "Array" {for ($ I = 0; $ I $$ a_define [$ I] = $ CUR [$ A_DEFINE_UP [$ I]];} $ A_RS [$ Lower] [$ I] = $$ a_define [$ I]; Use Digital Access $ A_RS [$ LOWER] [$ A_DEFINE [$ I]] = $$ a_define [$ I]; Use some to access $ A_RS [$ Lower] [$ A_DEFINE_UP [$ I] = $$ a_define [$ I]; use capital access}} elseif (TRIM ($ A_DEFINE) <> "") {if ($ CUR [$ A_DEFINE_UP] <> $$ a_define) {$$ a_define = $ Cur [$ A_DEFINE_UP]; $ A_RS [$ LOWER] [0] = $$ a_define; access $ A_RS [$ loc] with a number [$ A_DEFINE] = $$ A_Define; Some visits $ A_RS [$ Lower_up] = $$ A_Define; use capital access} $ loc ;} else {Break; if $ i_end- $ i_start = 0 indicates the record and jump out the while loop}} else {$ CNT ; if $ CNT <$ i_START, $ CNT }}} While ends the handle and returns the query data (a two-dimensional array) OCIFREESTATEMENT ($ this -> i_stmtid); Return $ A_RS;} Function end function name: db_change ($ C_SQL, $ A_BIND) RE: DB Change Parameters: $ c_sql SQL Statement $ A_BIND The field that needs to be bound.

Array type return value: Boolean Note: INSERT, DELETE, UPDATE Universal Function DB_Change ($ C_SQL, $ A_BIND = ") {if (! $ C_sql) {alertexit (" Parameter is not full! ");} Check parameter connection detection IF ($ this -> i_linkid == "") {Alertexit ("Our database is busy, please contact it later!");} Format detection $ this -> i_stmtid = = ociparse ($ this -> i_linkid, $ c_sql) ; if (! $ this -> i_stmtid) {alertexit ('sql format error! Contact programmer');} Bind IF (GetType ($ A_BIND) == "Array") {for ($ I = 0; $ I i_stmtid, ": $ A_BIND [$ I]", & $$ A_bind [$ I], -1); Bind}} Elseif (TRIM ($ A_BIND) <> "" is not an array Yes, it is character {Global $$ a_bind; $$ a_bind = Stripslashes ($$ a_bind); $$ a_bind = STR_REPLACE (" I_stmtid, ": $ arrbind", & $$ a_bind, -1);} Perform and detect if it is successful if (! Ociexecute ($ this -> i_stmtid, oci_default)) {echo " Perform an error: SQL error: $ c_sql
"; return false;} / * Replies of affected rows Global $ I_CHANGENUM; $ I_CHANGENUM = OCINUMROWS ($ this -> i_stmtid); * / Release Handle, Passage OCIFREESTATEMENT ($ this -> i_stmtid); Return true;} function name: DB_DELETE ($ c_sql) Role: Delete Parameters: C_SQL SQL statement Return Value: Boolean Note: This function is just to use intuitive, intrinsically call db_change () Function DB_DELETE ($ c_sql) {Return $ this -> db_change ($ c_sql);} function name: db_insert ($ c_sql, a_bind ) The role: INSERT parameters:

转载请注明原文地址:https://www.9cbs.com/read-5443.html

New Post(0)