- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
$statement = $pdo->prepare(
"if not exists
(select daily_serving_start, daily_serving_end,
weekly_service_off, one_time_service_off
from menu_availability_rules
where
(daily_serving_start = :start0 or
(daily_serving_start is null and :start1 is null)) and
(daily_serving_end = :end0 or
(daily_serving_end is null and :end1 is null)) and
(weekly_service_off = :weekly0 or
(weekly_service_off is null and :weekly1 is null)) and
(one_time_service_off = :once0 or
(one_time_service_off is null and :once1 is null)))
begin
insert into menu_availability_rules
(daily_serving_start, daily_serving_end,
weekly_service_off, one_time_service_off)
values (:start2, :end2, :weekly2, :once2)
end
if not exists
(select menu_id, daily_serving_start, daily_serving_end,
weekly_service_off, one_time_service_off
from menu_availability
where
menu_id = :menu_id0 and
(daily_serving_start = :start3 or
(daily_serving_start is null and :start4 is null)) and
(daily_serving_end = :end3 or
(daily_serving_end is null and :end4 is null)) and
(weekly_service_off = :weekly3 or
(weekly_service_off is null and :weekly4 is null)) and
(one_time_service_off = :once3 or
(one_time_service_off is null and :once4 is null)))
begin
insert into menu_availability
(menu_id, daily_serving_start, daily_serving_end,
weekly_service_off, one_time_service_off)
values (:menu_id1, :start5, :end5, :weekly5, :once5)
end");