By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,945 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,945 IT Pros & Developers. It's quick & easy.

how to insert automatically data into mysql table by php after fixed time duration

P: 6
Actually i am creating a punching tool in which we will punch so that if someone will not that after 6 hour automatically a query would be submitting like a notification so please tell me how can i insert data into mysql table in php automatically.
Apr 17 '19 #1
Share this Question
Share on Google+
8 Replies


gits
Expert Mod 5K+
P: 5,329
not sure what a 'punching tool' is - but i would say that this requirement is to be implemented in another way. you just need a timestamp that is always updated on a request so the application can always compare that timestamp and see if the entry is 'too old' or not.

to have the possibility to update something in an interval by php it would require to run a php process indefinitly - which basically could be done by running a php process at the commandline - preferably as a service on that machine - which isnt a preferable way to do things since the above solution would avoid that already. It would have to check all entries all the time and see which one to update - so it would create unnecessary load on the machine ressources as well as on the database.
Apr 17 '19 #2

P: 6
okey but how to insert data automatically in mysql database.
Apr 17 '19 #3

gits
Expert Mod 5K+
P: 5,329
why would you need that? there shouldn't be a reason for that - since it simply can be done with correct updates and comparisons of a timestamp.

you would need to explain more what exactly you want to achieve - there are really rare needs of having something like a service that does inserts or updates in a DB periodically - most can/should be solved without such for already mentioned reasons.
Apr 17 '19 #4

P: 6
i need for a reason that is if employee not submit his entry at office time than after 6 hour automatically system submit a query for him.
Apr 17 '19 #5

gits
Expert Mod 5K+
P: 5,329
let me try to understand that since its still unclearly explained:

an employee should do some entry and when he did not do that entry - basically a record is missing.

now you want to insert some default record for that automatically?
Apr 17 '19 #6

P: 6
Yes, I want a message should be automatically insert into database like for your understanding like notification.
Apr 18 '19 #7

gits
Expert Mod 5K+
P: 5,329
ok - but whatfor? basically at some point the records will be read from the database - so while doing that a program could react to any missing or 'too old' entries by simply comparing a timestamp or existence of a record. this way the DB wouldnt be polluted with default entries that wouldnt be needed - since a program can generate such notifications on the fly.

if you still insist to insert something into the DB you might simply write a php program that checks which records to be added and start it from a cronjob after the office hours for example. that way there could be a 'job' that inserts those records once per day.
Apr 18 '19 #8

P: 6
ok Thank you gits i also thinking to do with cronjob but that is possible only on live server not local server. thank you.
Apr 18 '19 #9

Post your reply

Sign in to post your reply or Sign up for a free account.