php - MySQL get data older than 30 minutes and perform some tasks -


i trying make coupon system, got stuck something. want make function gets data coupon_session time (datetime) older 30 minutes. each of results, want fetch "code" row, , after want delete row.

i've figured out how retrieve data, rest kinda hard me. guys bit?

this code fetching > 30 min old rows:

mysql_query("get * `coupon_session` timestampdiff(minute,time,now()) > 30"); 

the code fetch want is:

select cs.code coupon_session cs time < date_sub(now(), interval 30 minute); 

deleting problem, because value of now() changes. have several choices, such as:

  • get list of ids delete in application , delete (probably safest method).
  • calculate "now" in application , use same value select , delete (also safe).
  • calculate maximum time returned select , use subsequent delete.

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -