SELECT SQL_CALC_FOUND_ROWS
restaurants.cache_visits, restaurants.oo_presence,
restaurants.id, restaurants.booking, restaurants.oo, restaurants.restaurant, restaurants.restaurant_url,restaurants.picture, restaurants.picture_date, restaurants.city, restaurants.zipcode, restaurants.hb, restaurants.latitude, restaurants.longitude,
restaurants.oo_delivery_type, restaurants.oo_takeaway, restaurants.cache_gold, restaurants.cache_favorite, restaurants.cache_ads_offer, restaurants.oo_preparation_time, restaurants.oo_preparation_time_1, restaurants.oo_preparation_time_2, restaurants.oo_preparation_time_3, restaurants_delivery_areas.delivery_time, restaurants_delivery_areas.minimum_order_lunch, restaurants_delivery_areas.minimum_order_dinner,
ro.discount_rate, ro.offer_fr, ro.offer_en, ro.description_fr, ro.description_en,
gcp.localite_fr, gcp.localite_en,
restaurants.cache_cuisines_fr AS cuisines,
IF( ((ads_cpc.date_end IS NOT NULL AND ads_cpc.date_start <= UNIX_TIMESTAMP() AND ads_cpc.date_end >= UNIX_TIMESTAMP()) OR (ads_cpc.date_end IS NULL AND ads_cpc.date_start <= UNIX_TIMESTAMP())) AND ads_cpc.daily_balance>=ads_cpc.cpc, ads_cpc.id, NULL) AS id_ads_cpc,
IF( ((ads_cpc.date_end IS NOT NULL AND ads_cpc.date_start <= UNIX_TIMESTAMP() AND ads_cpc.date_end >= UNIX_TIMESTAMP()) OR (ads_cpc.date_end IS NULL AND ads_cpc.date_start <= UNIX_TIMESTAMP())) AND ads_cpc.daily_balance>=ads_cpc.cpc, ads_cpc.cpc,0) AS cpc
, addresses.id AS id_address, restaurants_distances.distance AS address_distance,lunch_start_h, lunch_start_m, dinner_start_h ,dinner_start_m, lunch_end_h, lunch_end_m, dinner_end_h ,dinner_end_m
FROM restaurants
LEFT JOIN ads_cpc ON restaurants.id = ads_cpc.id_restaurant AND ads_cpc.status=1
LEFT JOIN restaurants_offers ro ON restaurants.id = ro.id_restaurant AND ro.date_start <= UNIX_TIMESTAMP() AND ro.date_end >= UNIX_TIMESTAMP() AND ro.status=1 AND ro.delivery=1
LEFT JOIN geo_cp gcp ON restaurants.id_cp = gcp.id
LEFT JOIN addresses ON addresses.id=0
LEFT JOIN restaurants_delivery_areas_zipcode ON restaurants.id=restaurants_delivery_areas_zipcode.id_restaurant AND restaurants_delivery_areas_zipcode.id_cp=addresses.id_cp
LEFT JOIN restaurants_delivery_areas ON restaurants_delivery_areas_zipcode.id_area=restaurants_delivery_areas.id
LEFT JOIN restaurants_distances ON addresses.id=restaurants_distances.id_address AND restaurants.id=restaurants_distances.id_restaurant
LEFT JOIN restaurants_cuisines ON restaurants.id=restaurants_cuisines.id_restaurant
LEFT JOIN cuisines ON restaurants_cuisines.id_cuisine=cuisines.id
LEFT JOIN restaurants_dishes2 ON restaurants.id=restaurants_dishes2.id_restaurant
LEFT JOIN dishes2 ON restaurants_dishes2.id_dish2=dishes2.id
LEFT JOIN dishes1 ON dishes2.id_dish1=dishes1.id
LEFT JOIN restaurants_hours_orders ON restaurants.id=restaurants_hours_orders.id_restaurant AND day=2 LEFT JOIN holidays_jewish ON holidays_jewish.date_start <= UNIX_TIMESTAMP() AND holidays_jewish.date_end >= UNIX_TIMESTAMP()
WHERE 1
AND restaurants.oo=1 AND restaurants.oo_delivery=1 AND restaurants.subscription=1 AND restaurants.status=1 AND cuisines.cuisine_url_fr IN ('snacking_fr','halal','poulet','sushis') AND dishes1.dish1_url_fr IN ('plateaux_traiteur') AND (
restaurants.oo_presence=1
OR
restaurants.oo_preorder=1
)
GROUP BY restaurants.id
ORDER BY oo_presence DESC, cpc DESC, IF((restaurants.oo_delivery_type=1 AND distance<=3.5) OR restaurants.oo_delivery_type=2,0,1) ASC, restaurants.rank_order DESC, restaurants.id DESC
Warning: file_put_contents(/home/sites/v1/monresto/logs/sql_debug.log): failed to open stream: Permission denied in /home/sites/v1/monresto/www_v2/classes/Spdo.php on line 149