dtv8189 2013-03-19 09:25
浏览 30
已采纳

如何通过同时进行两次呼叫来阻止同一用户

I want to stop user to make two call at same time. Because if there is two call at same time it create bug in my application and update wrong info. I want it to finish first activity of user and give a error if user try to make two call at same time.

I am recording all user activity in table ->

table feed ->

......................................................
id   ! user  !  value  !  start !  finished ! timestamp
......................................................
7    !  22   !  100000 !    ok  !    ok     ! -------- 
......................................................
6    !  22   !  251632 !    ok  !    ok     ! --------
......................................................
5    !  53   !  125469 !    ok  !    ok     ! --------
......................................................
4    !  20   !  458962 !    ok  !    ok     ! --------
......................................................
3    !  19   !  124587 !    ok  !    ok     ! --------
......................................................
2    !  17   !  321457 !    ok  !    ok     ! -------- 
......................................................

I am recording data this way.

  • When user activity start it update : user, value and start as ok
  • when user finished activity it update : finished as ok

Now i am very confused how to check and stop two request at same time of a same user.

I am using php and mysql

thanks

  • 写回答

3条回答 默认 最新

  • dongwei2983 2013-03-19 09:52
    关注

    In your database, make a column like "alreadyInUse", mark it as true when a user makes a call and mark it as false, when the user will be done. While handling other users, always check whether alreadyInUse is false or not and if it's false, only then proceed further. I would suggest you to use threads and synchronization in PHP, for getting better results.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程