Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql SQL社交-在线用户_Mysql_Social Networking - Fatal编程技术网

Mysql SQL社交-在线用户

Mysql SQL社交-在线用户,mysql,social-networking,Mysql,Social Networking,我有一张桌子 CREATE TABLE `tbl_users` ( `user_id` int(11) NOT NULL auto_increment, `user_username` tinytext NOT NULL, `user_password` tinytext NOT NULL, `user_email` tinytext NOT NULL, `user_enabled` tinyint(4) NOT NULL default '1', `user_verif

我有一张桌子

CREATE TABLE `tbl_users` (
  `user_id` int(11) NOT NULL auto_increment,
  `user_username` tinytext NOT NULL,
  `user_password` tinytext NOT NULL,
  `user_email` tinytext NOT NULL,
  `user_enabled` tinyint(4) NOT NULL default '1',
  `user_verified` tinyint(4) NOT NULL default '0',
  `user_verified_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `user_signup_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `user_login_date` datetime default NULL,
  `user_status` mediumtext NOT NULL,
  `user_online` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`user_id`)
)
每次用户访问网站时,user\u login\u date都会更新,并且user\u online设置为1,这意味着他处于联机状态

如果用户上次访问是在10分钟前,我可以发送什么查询以将在线用户切换到0(离线)

我已经这样做过了

UPDATE tbl_users SET user_online = '0' WHERE (NOW() - user_login_date) > INTERVAL 10 minute

但是这没有帮助。

您应该对常数进行计算,以便可以使用用户登录日期的索引:

UPDATE tbl_users
SET user_online = '0'
WHERE NOW() - INTERVAL 10 MINUTE > user_login_date

这没有多大意义。这是否意味着如果我仍然处于活动状态,但在11分钟前登录,则我不在线?不。我的意思是每次加载页面时,登录日期都会更新。