每个用户每天执行一次直到过期
execute once a day per user until expire
我有一个带有订阅方式的系统。用户将提前 3 天收到他的订阅即将 运行 结束的通知。
消息有效,但每次用户按确定并浏览时,都会发送新的 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/user,直到到期日吗?
将您的用户 table 的唯一标识符添加到事件 table。这样您就可以从事件 table 中为用户和事件时间快速 SELECT 以确定是否应该发生 INSERT。
感谢@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 和今天日期的行,如果没有则插入。
我有一个带有订阅方式的系统。用户将提前 3 天收到他的订阅即将 运行 结束的通知。
消息有效,但每次用户按确定并浏览时,都会发送新的 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/user,直到到期日吗?
将您的用户 table 的唯一标识符添加到事件 table。这样您就可以从事件 table 中为用户和事件时间快速 SELECT 以确定是否应该发生 INSERT。
感谢@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 和今天日期的行,如果没有则插入。