CDbException

CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND lft<= AND parent_id=1 ' at line 25. The SQL statement executed was: select a.url, a.name, gallery_photo.id as file_name, gallery_photo.name as alt, gallery_photo.description from ( SELECT sitemap.id, sitemap.name, sitemap.url, max(gallery_photo.rank) as max_rank FROM excursions INNER JOIN sitemap ON (excursions.sitemap_id = sitemap.id) INNER JOIN gallery ON (excursions.gallery_id = gallery.id) INNER JOIN gallery_photo ON (gallery.id = gallery_photo.gallery_id) WHERE sitemap.id IN (select id from (select rgt, lft from sitemap where id = ( select id from sitemap where rgt>= AND lft<= AND parent_id=1 )) a, sitemap where a.rgt>= sitemap.rgt and a.lft<= sitemap.lft and id != and type = 3) GROUP BY sitemap.id, sitemap.name, sitemap.url ORDER BY RAND() LIMIT 3 ) a, sitemap, gallery, gallery_photo where a.id = sitemap.id and a.max_rank = gallery_photo.rank and gallery.id = gallery_photo.gallery_id (/home/u611/prometheus-travel.com/WWW/framework/yiilite.php:8683)

#0 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(8607): CDbCommand->queryInternal('fetchAll', Array, Array)
#1 /home/u611/prometheus-travel.com/WWW/chernogoriya/protected/controllers/ExcursionsController.php(180): CDbCommand->queryAll()
#2 /home/u611/prometheus-travel.com/WWW/chernogoriya/protected/controllers/ExcursionsController.php(38): ExcursionsController->getRandom3(NULL)
#3 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(3763): ExcursionsController->actionView()
#4 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(3275): CInlineAction->runWithParams(Array)
#5 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(3260): CController->runAction(Object(CInlineAction))
#6 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(3250): CController->runActionWithFilters(Object(CInlineAction), Array)
#7 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(1689): CController->run('view')
#8 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(1609): CWebApplication->runController('excursions/view')
#9 /home/u611/prometheus-travel.com/WWW/framework/yiilite.php(1135): CWebApplication->processRequest()
#10 /home/u611/prometheus-travel.com/WWW/chernogoriya/index.php(13): CApplication->run()
#11 {main}