muttley91
muttley91

Reputation: 12674

Publish article by date by scheduling a PHP/MySQL INSERT

I have an existing system to submit articles using PHP into a MySQL database. I would like to implement some sort of queue, so I was wondering if I could allow the submitter to select a date/time and then the Insert would perform at that time. Is this possible?

Upvotes: 1

Views: 1296

Answers (3)

Jeshurun
Jeshurun

Reputation: 23186

A better way to accomplish this is not to time the insert, but to time the publishing of the article. Instead of inserting at a specified time:

  • If the author selects a time that is in the future, add the time to publish_time column
  • When displaying the article only display the ones in which publish_time is in the past.

Upvotes: 5

Nikola K.
Nikola K.

Reputation: 7155

You can setup a MySQL Event or, probably better solution, setup a cron job, if you're on Linux.

Alternatevely, you could try with phpJobScheduler.

Upvotes: 3

mrok
mrok

Reputation: 2710

You can create additional table in DB ex: article_to_publish with publish_date column and then run some publish action by cron.

If you need more fun you can look at http://celeryproject.org/

Upvotes: 1

Related Questions