By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 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.
5 Days Ago #1
Share this Question
Share on Google+
8 Replies


gits
Expert Mod 5K+
P: 5,223
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.
5 Days Ago #2

P: 6
okey but how to insert data automatically in mysql database.
5 Days Ago #3

gits
Expert Mod 5K+
P: 5,223
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.
5 Days Ago #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.
5 Days Ago #5

gits
Expert Mod 5K+
P: 5,223
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?
5 Days Ago #6

P: 6
Yes, I want a message should be automatically insert into database like for your understanding like notification.
4 Days Ago #7

gits
Expert Mod 5K+
P: 5,223
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.
4 Days Ago #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.
4 Days Ago #9

Post your reply

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