Php, website visit ip according to time record

Business requirements, to record the visit record of the web page, according to ip, but now add one, according to the time, if the ip address is 202.192.26.26, and visited at 15:00, he will not record the visit to this web page within an hour, but will still record the visit to other web pages, how to write the database and how to do the php logic

Mar.12,2021

then judge according to the URL visited, you are going to do the user heat map of the website, which pages are concerned by users under the data analysis, in fact, if the needs are clear, you can directly find the ready-made solution, there is no need to think about it as a whole.


TP5 can do this.
there is a record IP field in the database, and we temporarily name it: ip
record access time field create_time
record access node field: node

Open model automatic write timestamp

$ip = request()->ip();
$node = request()->url();
$result = (new ())->where('ip,$ip)->where('node',$node)->find();
if(null === $result || $result['create_time'] < time()-3600 ){
    (new ())->save([
     'node'=>$node,
     'ip'=>$ip
    ]);
}

it should be possible to do the same

$currTime = time()-3600;
$result = (new ())->where('ip,$ip)->where('node',$node)->whereTime('create_time','<',$currTime)->find();
if(null === $result){
    (new ())->save([
     'node'=>$node,
     'ip'=>$ip
    ]);
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea334c-47a00.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea334c-47a00.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?