Notify every 2 hours if new data is entered

0

I am trying to create a system for Cron to execute a PHP file every 2 hours, and check if there was any record inserted in a certain table, if there are new records, know the total amount of new records in the meantime.

The only approach I thought was to query a COUNT , save the amount of records in a new table, and then execute the query that will send the notification if it has new records.

The question is: Is this approach ideal? Is something easier or even more correct?

    
asked by anonymous 26.10.2018 / 00:51

1 answer

1

Your approach works, but if the previous table has some datetime field of the insertion time for you whenever you run cron take the last hour executed and query records from that time, if you have records after the last date new records. cron saves a log every time it is run, to get the log date, and run from there!

    
26.10.2018 / 14:01