每个用户每天执行一次,直到过期

时间:2015-03-20 11:10:18

标签: mysql sql session caching asp-classic

我有一个订阅方法的系统。用户将收到通知,表示他的订阅将提前3天用完。

该消息有效,但每次用户按下OK并浏览时,都会发送一个新的sql插件。

我想要的是用户每天只收到消息。

Dim themsg = "Your subscription is about to end bla bla"
Set almost = ObjConn.execute("Select * from users where expire <= '"& DateAdd("d", -3, Date()) &"'")
If almost.eof then
Response.write "No users about to finish"
Else
dim sql
sql = "insert into events(uid, event, msg, sended, need_confirm, eventtime)"
sql = sql & " VALUES "
sql = sql & "('"& almost("id") &"', "
sql = sql & "'send_msg', "
sql = sql & "'"& themsg &"', "
sql = sql & "'1', "
sql = sql & "'1', "
sql = sql & "'"& Now() &"')"
on error resume next
ObjConn.execute sql,recaffected
End if

因此,每当您进入此页面时都可以看到,将发送新的插入内容。我可以限制它,以便它只发送给这个uid /用户一天,直到有效期为止?

2 个答案:

答案 0 :(得分:0)

将users表中的唯一标识符添加到events表中。这样,您可以从事件表中为用户和事件时间快速执行SELECT,以确定是否应该发生INSERT。

答案 1 :(得分:0)

感谢@ jradich1234让我知道如何做到这一点

在事件'checkday'中添加了新专栏

然后添加

Set kollar = ObjConn.execute ("Select * from events where uid='"& slut("id") &"' AND checkday='"& Date() &"'")
If kollar.eof Then

<<THE SQL INSERTION HERE >>

Else

Response.write "Already sent"

End if

因此,检查具有相同ID&amp;的行。今天发现,如果没有插入。