积分转赠php代码怎么实现 财富值17

2016-07-22 20:24发布

付费偷看设置
发送
3条回答

其实就是将积分相关的数据更新一下,赠送者减去,获赠者增加,最多再记录一下这个操作

点击转赠,执行修改数据库,拿到对方的id,执行修改语句,给对方积分增加相应的积分就可以了

例如:表 score_s

create table score_s(

id int primary key ,

score int #积分

);

insert into score_s values(1,1);

insert into score_s values(2,2);


id为2的用户的积分赠送1分给id为1的用户

update score_s set score=1+score where id=1;

update score_s set score=score-1 where id=2;

这就是一个积分的转赠。

当然,如果SQl服务器支持事务、触发器的话,建议在数据库那边写上,减轻写代码的压力。

一周热门 更多>