SELECT b.banners_id,
b.banners_title,
b.banners_text,
b.banners_url,
b.banners_image,
b.banners_group,
b.status,
date_format(b.date_scheduled, '%Y%m%d') as date_scheduled,
date_format(b.expires_date, '%Y%m%d') as expires_date,
b.max_shows,
b.max_clicks,
b.new_window,
b.date_status_change,
c.parent_id as cpid,
c.categories_id as c_id,
cc.categories_id as cc_id,
ccc.categories_id as ccc_id
FROM (banners b INNER JOIN banners_to b2
ON b.banners_id = b2.banners_id)
LEFT JOIN categories c
ON (b2.banners_to_id = c.parent_id)
LEFT JOIN categories cc
ON (c.categories_id = cc.parent_id)
LEFT JOIN categories ccc
ON (cc.categories_id = ccc.parent_id)
LEFT JOIN manufacturers m
ON (b2.banners_to_id = m.manufacturers_id)
LEFT JOIN products p
ON ( p.products_id = '' )
WHERE b.status = '1' AND
b.banners_place = 'top' AND
(
(
b2.banners_to_type = 'b' AND
( ( b2.banners_to_type = 'b' AND
( m.manufacturers_nID = 'cata' OR b2.banners_to_id = 0 OR b2.banners_to_id = '0')
) OR
( b2.banners_to_type <> 'b' AND
( b2.banners_to_id = 'cata' OR
(b2.banners_to_type = 'c' AND
( c.categories_id = 'cata' OR
cc.categories_id = 'cata' OR
ccc.categories_id = 'cata'
)
)
)
)
)
) OR p.manufacturers_id = b2.banners_to_id
)
AND
( (date_scheduled IS NULL) OR
(date_format(now(), '%Y%m%d') >= date_scheduled) ) AND
( (expires_date IS NULL) OR
(date_format(now(), '%Y%m%d') <= expires_date) )
GROUP BY b.banners_id
ORDER BY ccc_id, cc_id, c_id, cpid
LIMIT 2
array(1) {
["filter_id"]=>
string(4) "cata"
}
В этой категории нет товаров!