我在做一个复杂的项目。它的特点是在一天的特定时间内,在特定的日子里,最准时地显示广告。假设我的数据库里有20条广告,4条是每天显示1小时的14条数据。每天展示3小时,持续24天。10人每天展示6小时,持续30天。
由于管理员是为它创建计划的人,所以我有一个表,它使用以下列来处理:
ad_plans:
$table->string('ad_type');
$table->string('duration');
$table->string('display_time');
$table->string('amount');现在,每个ad_placement都属于上面的一个计划,所以我在ad_placements表中有如下内容:
$table->string('ad_plan_id');
$table->string('title');
$table->string('image');
$table->string('description');
$table->string('url');
$table->string('time_end')->nullable();
$table->string('duration_end')->nullable();
$table->enum('is_approve', ['Approved', 'Pending'])->default('Pending');
$table->string('view')->nullable();配置了关系之后,创建计划和位置就可以工作了。在我的股票是如何显示这些数据从数据库中最及时的一个特定的小时在指定的日子。
请朋友们帮帮我,我正在讨论如何实现它的逻辑。
发布于 2020-06-12 06:44:53
Php是一种基于服务器的技术,没有时间感知。
如果你想让时间意识到,你有两个选择:
)
我的建议是编写一个getAdsForDateTime(DateTime $datetime)函数,该函数将查询数据库以获得在给定时刻显示的广告。
此函数将由您选择的(并了解时间的)方法对应用程序所需的规范进行调用。
https://stackoverflow.com/questions/62337877
复制相似问题