SelenIT
Такой sql не срабатывает. Вот такой он полностью у меня получился:
[sql]
SELECT t2.id, t2.parent_id, t2.level, t2.title, t2.url, t2.handler, t2.source_id, t1.url, 1+IF(t1.id IS NULL,0,1) AS count FROM structure t0 LEFT JOIN structure t1 ON (t1.parent_id = t0.id AND t1.url = 'ti' AND t1.site_spb = 1 AND t1._disabled = 0 AND t1._deleted = 0) INNER JOIN structure t2 ON 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 = 'main'
[/sql]
-~{}~ 02.08.05 05:15:
Не очень хороший.
Вот более удобный пример:
[sql]
SELECT t3.id, t3.parent_id, t3.level, t3.title, t3.url, t3.handler, t3.source_id, t1.url, t2.url, 1+IF(t1.id IS NULL,0,1)+IF(t2.id IS NULL,0,1) AS count FROM structure t0 LEFT JOIN structure t1 ON (t1.parent_id = t0.id AND t1.url = 'news' 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 = '2005' AND t2.site_spb = 1 AND t2._disabled = 0 AND t2._deleted = 0) INNER JOIN structure t3 ON 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 = 'main'
[/sql]
Результат:
Array
(
[id] => 1
[parent_id] => 0
[level] => 0
[title] => Главная
=>
[handler] => main
[source_id] => 0
[count] => 1
)
Тоесть url пустой.