发布网友 发布时间:2022-04-08 04:06
共3个回答
懂视网 时间:2022-04-08 08:27
function Query($sql,$prms){ $db = " (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = XXX)(PORT = 1521)) (CONNECT_DATA = (SID=orcl) (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )"; $db_uname = "xxx"; $db_upass = "XXXXXX"; $conn = oci_connect($db_uname, $db_upass, $db); $stmt = oci_parse($conn, $sql); if(is_array($prms)){ foreach ($prms as $key => $val){ oci_bind_by_name($stmt, $key, $val); } } oci_execute($stmt, OCI_DEFAULT); $rownum = oci_fetch_all($stmt, $result); oci_free_statement($stmt); oci_close($conn); return $result; } function BeginTran(){ $db = " (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = XXX)(PORT = 1521)) (CONNECT_DATA = (SID=orcl) (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )"; $db_uname = "xxx"; $db_upass = "xxx"; $conn = oci_connect($db_uname, $db_upass, $db); return $conn; } function CloseConn($conn){ oci_close($conn); } function Commit($conn){ oci_commit($conn); CloseConn($conn); } function RollBack($conn){ oci_rollback($conn); CloseConn($conn); } ?><?php require ‘db.php‘; // $res = Query("select * from customerinfo where rownum < 100", null); // for($i = 0;$i< 99;$i++){ // foreach ($res as $data){ // echo $data[$i]; // } // } $sql = "insert into hostparam (paramtype,paramvalue) values (:ptype,:pval)"; $conn = BeginTran(); $num = 0; try { $stmt = oci_parse($conn, $sql); $ptype = "1"; $pval = "2"; oci_bind_by_name($stmt, ":ptype", $ptype); oci_bind_by_name($stmt, ":pval", $pval); oci_execute($stmt,OCI_DEFAULT); $num = oci_num_rows($stmt); Commit($conn); } catch (Exception $e) { RollBack($conn); } echo $num; ?>
php实现oracle操作
标签:
热心网友 时间:2022-04-08 05:35
putenv ("ORACLE_BASE=/ora");热心网友 时间:2022-04-08 06:53
http://www.pconline.com.cn/pce/empolder/wz/php/10211/108149.html用PHP连接Oracle数据库