Best way to determine if a user went offline in MySQL -
so script forces user send "ping" every 10 minutes. inserts record mysql user id , current timestamp.
what achieve seeing if of users went offline recently. in theory selecting online (20ish minutes ago) user, checking if there has not been ping in past 11 minutes except don't seem able figure out how. have far:
select * status time > (curtime() - 1200) , time < (curtime() - 660)
i have add, in combination php shouldn't matter.
any appreciated.
i try :
select timediff(curtime(), max(s.time)) duration, s.user status s group s.user having duration > 660 , duration < 1200;
if username not stored in status table. should perform join between status , user.
you can use between statement if want check duration specific range too.
edit : madbreaks "recently" constraint. can add , duration < xxxx not retrieve old durations , keep "recent" status in result set.
Comments
Post a Comment