English 中文(简体)
如何自动删除表格中的数据?
原标题:How to erase data from table automatically?

我有一张桌子

它有四个字段 : Phone_ number( 主要密钥), City_ name, Category_ product 和 子_ Category

I am develoing a php application such based on an sms gateway. whenver a user sends and sms requesting a product service, his details will be saved in this table.

Now when a user sends an SMS ,i will store the details in the table,and wait for the user to send back an sms with further details as per required.

Now what i want to do is: if a user does not respond in lets say 15 min his details should be deleted from the table automatically. How should i proceed?

最佳回答

您在表格中添加一个列, 以存储发送时间 。

然后,你不得不选择,你要么可以运行金字塔工作来清理数据,要么可以清理当另一个用户发送信号等时无效的记录。由于您将时间存储在数据中,您也可以很容易地将超时时间从15分钟后更改到15分钟后。

问题回答

您必须使用一些日程安排 。 PHP 没有本地对日程安排的支持 。 我建议创建一个 decktop 复制程序或一个服务, 监听短信回复的表格 。 如果它没有得到响应, 它将会删除对应的记录 。 您的工作将会无限运行 。

如果这是一张有许多记录的表格, 您应该设置一个预置表格, 然后在命令发出时复制记录。 这样, 如果您想要清理预置表格, 如果它开始变慢, 您可以随时清理它 。

正如本所说,它应该有一个检查的时间戳。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签