$orderdate = strtotime($this->input->get('orderdate')); $today = strtotime(date('Y-m-d',time()));
$num = ceil(($orderdate - $today)/86400); $conn = oci_connect('username','password',"(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST=host)(PORT = 1521))(CONNECT_DATA =(SID=sid)))"); $sql = 'BEGIN PROC_CREATEORDERDETAIL(:INPUTNUM); END;'; $stmt = oci_parse($conn,$sql); //编译 oci_bind_by_name($stmt,':INPUTNUM',$num,32); //参数绑定 if(oci_execute($stmt)){ echo "<script>window.alert("已重新生成当日订单明细"),location.href="http://bi.xiaoyou-game.com/order/lists";</script>";
存储过程:
create or replace PROCEDURE PROC_CREATEORDERDETAIL(INPUTNUM IN NUMBER) AS V_AMOUNT_REMAIN NUMBER; BEGIN DELETE FROM TBL_NEW_PLAN_HOUR T WHERE SUBSTR(T.PLAN_HOUR,0,10)=TO_CHAR(SYSDATE+INPUTNUM,'YYYY-MM-DD'); INSERT INTO TBL_NEW_PLAN_HOUR(ORDERID,DIM_HOUR,HOUR_AMOUNT,PLAN_HOUR,FINISHED_AMOUNT,SCRIPTPACKAGE) SELECT OL.ORDERID, T.DIM_HOUR, ROUND(OL.ORDERAMOUNT*T.RADIO/100) AS HOUR_AMOUNT, TO_CHAR(TO_DATE(OL.ORDERDATE,'YYYY-MM-DD HH24:MI:SS')+T.DIM_HOUR/24,'YYYY-MM-DD HH24:MI:SS') AS PLAN_HOUR, 0 AS FINISHED_AMOUNT, ol.SCRIPTPACKAGE FROM TBL_NEW_RADIO T,ORDERLIST OL WHERE OL.ORDERDATE=TO_CHAR(SYSDATE+INPUTNUM,'YYYY-MM-DD'); COMMIT; END;