简体   繁体   English

我应该使用哪个? SQL触发器还是Cron作业?

[英]Which should I use? SQL Triggers or Cron Jobs?

I am working on a scheduling system that allows for content managers to add content that will go live at a later set date. 我正在使用一个调度系统,该系统允许内容管理员添加将在以后的设置日期上线的内容。 My SQL/PHP knowledge is not the greatest and after some extensive research I am finding it difficult to figure the best option to use when building this system. 我的SQL / PHP知识不是最广,经过大量研究后,我发现很难在构建此系统时找出最佳选择。 Should I use Cron Jobs? 我应该使用Cron Jobs吗? or SQL Triggers? 或SQL触发器?

I am looking to make it so I can also execute some PHP along with the SQL commands that will set the content to live. 我正在努力做到这一点,因此我还可以执行一些PHP以及将内容设置为实时的SQL命令。

I would use neither. 我都不用。 I'd have a 'goLive' datetime and a 'retire' datetime for each piece of content. 对于每个内容,我都会有一个“ goLive”日期时间和一个“退休”日期时间。 Then when you select which content to show, you'd have a where clause like this 然后,当您选择要显示的内容时,将有一个where子句,像这样

where current timestamp between goLive and retire

Then your content appears at the 'goLive' time and disappears at the 'retire' time. 然后,您的内容在“ goLive”时间出现,在“退休”时间消失。

Thanks for all of the responses, all of it has been super useful in helping me come to a conclusion. 感谢所有答复,所有这些都对帮助我得出结论非常有用。 I will be using Cron Jobs to get this specific job done. 我将使用Cron Jobs完成此特定工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM