《PHP學(xué)習(xí):php 訪問(wèn)oracle 存儲(chǔ)過(guò)程實(shí)例詳解》要點(diǎn):
本文介紹了PHP學(xué)習(xí):php 訪問(wèn)oracle 存儲(chǔ)過(guò)程實(shí)例詳解,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
PHP編程php 訪問(wèn)oracle 存儲(chǔ)過(guò)程實(shí)例詳解
PHP編程比如我的本地Oracle數(shù)據(jù)庫(kù)有一個(gè)package,里面有一個(gè)存儲(chǔ)過(guò)程:
PHP編程
create or replace package PKG_TRANS_REL is
-- Author : test
-- Created :
-- Purpose : test
-- Public type declarations
PKG_NAME varchar2(20) := 'PKG_TRANS_REL';
--存儲(chǔ)過(guò)程,測(cè)試用
procedure pro_GC_withdraw(in_merch_no in varchar2,
in_withdraw_amt in number,
out_result out number,
out_errmsg out varchar2);
end PKG_TRANS_REL;
PHP編程包名是PKG_TRANS_REL,存儲(chǔ)過(guò)程是pro_GC_withdraw,這個(gè)存儲(chǔ)過(guò)程有四個(gè)參數(shù),兩個(gè)入?yún)?兩個(gè)出參.
PHP編程在PHP中通過(guò)pdo調(diào)用示例:
PHP編程
$this->_pdo = new PDO(PDO_DB_DNS, PDO_DB_USER, PDO_DB_PASSWORD);
$call = "CALL PKG_TRANS_REL.pro_GC_withdraw(?,?,?,?)";
try{
$stmt = $this->_pdo->prepare($call);
$stmt->bindParam(1, $merch_no);
$stmt->bindParam(2, $amount, PDO::PARAM_INT);
$stmt->bindParam(3, $result, PDO::PARAM_INT, 4);
$stmt->bindParam(4, $error_msg, PDO::PARAM_STR, 64);
$stmt->execute();
}catch (PDOException $e)
{
$msg = 'SQL:'.$e->getMessage();
$msg = iconv('GBK','UTF-8',$msg);
user_dump('SQL:'.$msg);
return false;
}
...
PHP編程bindParam第三個(gè)參數(shù)默認(rèn)是PDO::PARAM_STR,如果是其它類型就要指明
PHP編程入?yún)髦当容^簡(jiǎn)單,出參稍微復(fù)雜些,要指明長(zhǎng)度.
PHP編程感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/2011.html