Reputation: 61
my coding had regarding crontab in linux and php, what I want to do is my cronjob datetime is * * * * *, that mean it every minute also will checking the result, so once my result had check complete , it will insert to database, but now my results are keep inserting to database, so how to everyday insert only one record in database with the cronjob run every minute or how to stop keep inserting result to database?
thank you hope you guys reply me soonest
Upvotes: 0
Views: 2910
Reputation: 26941
You have to check if you have already inserted the date. Assuming your table is Table
and column that stores date is date
as timestamp
$sql = "select * from Tablewhere DATE(`date`) = CURRENT_DATE()";
$result = mysql_query($sql);
if (mysql_num_rows($result)>0){
//you already have inserted current date, handle this as you need
}
else{
//current date have not beed inserted, insert it as usual
}
This code does not check for sql errors and does not use prepared statments, but it's simple and provides you with a good idea to start.
Upvotes: 1
Reputation: 14941
Do the following:
Upvotes: 3