Иван Шумков
Новичок
SelenIT
C уровнями все здорово, но вот с title не все так просто:
[sql]
SELECT t4.id, t4.parent_id, t4.level, t4.title, t4.url, t4.handler, t4.source_id, t1.title AS title1, t2.title AS title2, t3.title AS title3 FROM structure t0 LEFT JOIN structure t1 ON (t1.parent_id = t0.id AND t1.url = 'fashion' AND t1.site_spb = 1 AND t1._disabled = 0 AND t1._deleted = 0) LEFT JOIN structure t2 ON (t2.parent_id = t1.id AND t2.url = '234123' AND t2.site_spb = 1 AND t2._disabled = 0 AND t2._deleted = 0) LEFT JOIN structure t3 ON (t3.parent_id = t2.id AND t3.url = '234' AND t3.site_spb = 1 AND t3._disabled = 0 AND t3._deleted = 0) INNER JOIN structure t4 ON t4.id = IF (t3.id IS NOT NULL, t3.id, IF (t2.id IS NOT NULL, t2.id, IF (t1.id IS NOT NULL, t1.id, t0.id))) WHERE t0.parent_id = 0 AND t0.site_spb = 1 AND t0._disabled = 0 AND t0._deleted = 0 AND t0.url = 'impressions'
[/sql]
На выходе получаем:
Array
(
[id] => 4
[parent_id] => 3
[level] => 1
[title] => Мода
=> fashion [handler] => list [source_id] => 0 [title1] => Мода [title2] => [title3] => ) Тоесть t1.title = t4.title Почему?
C уровнями все здорово, но вот с title не все так просто:
[sql]
SELECT t4.id, t4.parent_id, t4.level, t4.title, t4.url, t4.handler, t4.source_id, t1.title AS title1, t2.title AS title2, t3.title AS title3 FROM structure t0 LEFT JOIN structure t1 ON (t1.parent_id = t0.id AND t1.url = 'fashion' AND t1.site_spb = 1 AND t1._disabled = 0 AND t1._deleted = 0) LEFT JOIN structure t2 ON (t2.parent_id = t1.id AND t2.url = '234123' AND t2.site_spb = 1 AND t2._disabled = 0 AND t2._deleted = 0) LEFT JOIN structure t3 ON (t3.parent_id = t2.id AND t3.url = '234' AND t3.site_spb = 1 AND t3._disabled = 0 AND t3._deleted = 0) INNER JOIN structure t4 ON t4.id = IF (t3.id IS NOT NULL, t3.id, IF (t2.id IS NOT NULL, t2.id, IF (t1.id IS NOT NULL, t1.id, t0.id))) WHERE t0.parent_id = 0 AND t0.site_spb = 1 AND t0._disabled = 0 AND t0._deleted = 0 AND t0.url = 'impressions'
[/sql]
На выходе получаем:
Array
(
[id] => 4
[parent_id] => 3
[level] => 1
[title] => Мода
=> fashion [handler] => list [source_id] => 0 [title1] => Мода [title2] => [title3] => ) Тоесть t1.title = t4.title Почему?