簡體   English   中英

將變量從SQL過程傳遞到PHP

[英]Passing variables from SQL proceedure to PHP

我正在嘗試創建一個SQL過程,將結果返回到php頁面。

我希望能夠從php調用以下過程

call procedure_name($var1)

它將運行以下腳本:

-- ---------------------------------------------------------------------------------
-- pUIGetCliStmtGenFlag
--
-- This procedure returns the status of the Trading Period:
--
-- ---------------------------------------------------------------------------------


drop procedure if exists pUIGetCliStmtGenFlag;
delimiter //

create procedure pUIGetCliStmtGenFlag(
IN pTradingPeriodMonth      DATE
)
MODIFIES SQL DATA
COMMENT 'Checks if the TP has been closed'
begin

  SELECT trading_period_month, 
         dt_end, 
         amt_traded_system_ccy
  FROM   ca_trading_period
  WHERE  trading_period_month=$var1

-- If amt_traded_system_ccy is NULL give the TP an open status otherwise mark as closed

  IF amt_traded_system_ccy is NULL

    $tpstatus='open'

  ELSE

    $tpstatus='closed'

end;
//

delimiter ;

然后,我希望能夠在其余的php腳本中使用$tpstatus

我知道這很簡單,但這對我來說是全新的,我找不到正確的方法

您必須從php調用存儲過程,然后使用過程的OUT參數取回值。

請按照以下說明進行操作:

https://stackoverflow.com/a/48161/1291428

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM