MySQL - 博客文章调度系统
我正在使用 CodeIgniter 创建一个博客文章调度系统。我希望每天显示 10 个帖子。 posts
表中有一个名为 scheduled_date
的字段,我将获取小于或等于当前日期的帖子。当管理员用户向数据库添加新记录时,我需要一个 SQL 语句来帮助我计算数据库中最新日期的记录数。例如:
// 9 records returned for the date 2011-01-01 $numbers_of_records == 9; if($numbers_of_records == 10){ // inserts record with `scheduled_date`='2011-01-01' }else{ // inserts record with the date latest date +1 day }
我如何有效地完成这个任务?
谢谢
I am creating a blog post scheduling system using CodeIgniter. I want 10 posts to show up a day. There is a field in the posts
table named scheduled_date
which I will get the posts that are less than or equal to the current date. When an admin user adds a new record to the database, I need an SQL statement that somehow will help me COUNT the number of records with the latest date in the database. For example:
// 9 records returned for the date 2011-01-01 $numbers_of_records == 9; if($numbers_of_records == 10){ // inserts record with `scheduled_date`='2011-01-01' }else{ // inserts record with the date latest date +1 day }
How would I efficiently accomplish this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样就可以解决问题了。它简单而高效。
This will do the trick. It is simple and efficient.