vanillaforums/Garden — Issue #1242: Unknown column 'c.LastDiscussionID' in 'on clause'
Author: elifarley
Created: 2011-11-23 03:48:50+00:00
State: open

After upgrading to Vanilla 2.0.18.1 and visiting http:///utility/update, I see this error:

----------------------------------------------
Fatal Error in Gdn_Database.Query();

Unknown column 'c.LastDiscussionID' in 'on clause'
select c.*, co.DateInserted as `DateLastComment`, co.InsertUserID as `LastCommentUserID`, d.Name as `LastDiscussionTitle`, d.CountComments as `LastDiscussionCountComments`, d.InsertUserID as `LastDiscussionUserID`, d.DateInserted as `DateLastDiscussion`, uc.DateMarkedRead as `DateMarkedRead`, uc.Unfollow as `Unfollow`
from GDN_Category c
left join GDN_Comment co on c.LastCommentID = co.CommentID
left join GDN_Discussion d on d.DiscussionID = c.LastDiscussionID
left join GDN_UserCategory uc on uc.UserID = 2 and uc.CategoryID = c.CategoryID
where c.AllowDiscussions = :cAllowDiscussions
order by TreeLeft asc

The error occurred on or near: /usr/www/users/my_user/library/database/class.database.php
276:
277: if (!is_object($PDOStatement)) {
278: trigger_error(ErrorMessage('PDO Statement failed to prepare', $this->ClassName, 'Query', $this->GetPDOErrorMessage($this->Connection()->errorInfo())), E_USER_ERROR);
279: } else if ($PDOStatement->execute($InputParameters) === FALSE) {
280: trigger_error(ErrorMessage($this->GetPDOErrorMessage($PDOStatement->errorInfo()), $this->ClassName, 'Query', $Sql), E_USER_ERROR);
281: }
282: } else {
283: $PDOStatement = $this->Connection()->query($Sql);
284: }

Backtrace:
/usr/www/users/my_user/library/database/class.database.phpPHP::Gdn_ErrorHandler();
[/usr/www/users/my_user/library/database/class.database.php:280] PHP::trigger_error();
[/usr/www/users/my_user/library/database/class.sqldriver.php:1650] Gdn_Database->Query();
[/usr/www/users/my_user/library/database/class.sqldriver.php:676] Gdn_SQLDriver->Query();
[/usr/www/users/my_user/applications/vanilla/models/class.categorymodel.php:547] Gdn_SQLDriver->Get();
[/usr/www/users/my_user/applications/vanilla/controllers/class.categoriescontroller.php:177] CategoryModel->GetFull();
[/usr/www/users/my_user/applications/vanilla/controllers/class.categoriescontroller.php:177] CategoriesController->All();
[/usr/www/users/my_user/library/core/class.dispatcher.php:322] PHP::call_user_func_array();
[/usr/www/users/my_user/index.php:53] Gdn_Dispatcher->Dispatch();

Variables in local scope:
[Sql] 'select c.*, co.DateInserted as `DateLastComment`, co.InsertUserID as `LastCommentUserID`, d.Name as `LastDiscussionTitle`, d.CountComments as `LastDiscussionCountComments`, d.InsertUserID as `LastDiscussionUserID`, d.DateInserted as `DateLastDiscussion`, uc.DateMarkedRead as `DateMarkedRead`, uc.Unfollow as `Unfollow`
from GDN_Category c
left join GDN_Comment co on c.LastCommentID = co.CommentID
left join GDN_Discussion d on d.DiscussionID = c.LastDiscussionID
left join GDN_UserCategory uc on uc.UserID = 2 and uc.CategoryID = c.CategoryID
where c.AllowDiscussions = :cAllowDiscussions
order by TreeLeft asc'
[InputParameters] array (
':cAllowDiscussions' => '1',
)
[Options] array (
'ReturnType' => 'DataSet',
)
[ReturnType] 'DataSet'
[PDOStatement] array (
'queryString' => 'select c.*, co.DateInserted as `DateLastComment`, co.InsertUserID as `LastCommentUserID`, d.Name as `LastDiscussionTitle`, d.CountComments as `LastDiscussionCountComments`, d.InsertUserID as `LastDiscussionUserID`, d.DateInserted as `DateLastDiscussion`, uc.DateMarkedRead as `DateMarkedRead`, uc.Unfollow as `Unfollow`
from GDN_Category c
left join GDN_Comment co on c.LastCommentID = co.CommentID
left join GDN_Discussion d on d.DiscussionID = c.LastDiscussionID
left join GDN_UserCategory uc on uc.UserID = 2 and uc.CategoryID = c.CategoryID
where c.AllowDiscussions = :cAllowDiscussions
order by TreeLeft asc',
)

Additional information for support personnel:
Application: Vanilla
Application Version: 2.0.18.1
PHP Version: 5.3.8
Operating System: Linux
Server Software: Apache
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Request Uri: /
Controller: Gdn_Database
Method: Query