Home > database >  PHP get stored procedure @ out the value of the card in the last step. Fast cry is dead!
PHP get stored procedure @ out the value of the card in the last step. Fast cry is dead!

Time:09-24

Everyone a great god, and I modify a novel procedure, read the PHP mysql problems, all the way through, don't want to be stuck in the final with a judgment whether the transaction success of the stored procedure @ out worth it to get back up, please be sure to greatly help me!!!!!!

01 I listed first PHP content -
$query=JieqiQueryHandler: : getInstance (" JieqiQueryHandler ");//declare a new query instance
$u_q=@ mysql_query (" CALL lesgl. 01 (JIEQI_NOW_TIME, uid, $1000, @ jieguo) ");//execute statement
$jieguo=@ mysql_result ($u_q, 0, 'select @ jieguo');//the data table, fields have different [@, because without the @ error directly]

02 stored procedure code -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Four parameters
Shijian int 20 timestamp
Id int
Newgole int new website tokens, general 1000
Jieguo int transaction success of the return value of the out


The BEGIN

Declare u1 int.
Declare ok integer default 0; # define return results and initialise 0
Declare the continue handler for sqlexception set ok=1; Have any fault is a # 1
Declare the continue handler for the not found set ok=2; Article # not next to 2

The set u1=(SELECT ` egold ` FROM ` jieqi_system_users ` WHERE ` uid `=id); # the current number of tokens,
The set u1=u1 + newegole; # and prepaid phone content

start transaction; # start transaction


INSERT INTO ` lesgl `. ` jieqi_pay_paylog `

(` payid `, ` siteid `, ` buytime `, ` buyid `, ` money `, ` egoldtype `, ` egold `, ` paytype `, ` payflag `)

VALUES

(NULL, '0', shijian, id, newegole, '0', newegole, 'WeChat', '1');

The UPDATE ` jieqi_system_users ` SET ` egold `=u1 WHERE ` uid `=id;

If ok=1 then
ROLLBACK; # rollback
The set jieguo=0;
The select jieguo;
The else
COMMIT; # submit
The set jieguo=1;
The select jieguo;
end if;

END

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Please be sure to greatly help me! ! Genuflect is begged!!!!!
  • Related