更新时间:2023-12-01 21:06:10
就个人而言,当我进行视图跟踪时,我有以下列:
Personally, when I do view tracking, I have the following columns:
`id`
`identifier` : this is either the person's username or if they don't have an account, their IP
`date` : inserted using CURDATE()
`page_url`
在添加到该表之前,我运行以下查询,如果没有返回任何行,则插入该表以向该页面添加视图:
Before adding to this table, I run the following query and if there are no rows returned, then I insert into that table to add a view to that page:
SELECT id FROM views WHERE identifier = '$user_id' AND date = CURDATE() AND page_url = '$url' LIMIT 1
如果您希望多于/少于一天的时间范围来决定计算新的观看次数,则需要更改选择日期的方式.
You would want to change how you select the date if you want more/less than a day's timeframe for deciding to count new views.