diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php index 21c465d..a82ad5d 100644 --- a/code/widgets/ArchiveWidget.php +++ b/code/widgets/ArchiveWidget.php @@ -68,20 +68,20 @@ if(class_exists('Widget')) { if($this->DisplayMode == 'month') { $sqlResults = DB::query(" SELECT DISTINCT CAST($monthclause AS " . DB::getConn()->dbDataType('unsigned integer') . ") - AS \"Month\", - $yearclause AS \"Year\" - FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" - ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\" - WHERE \"ParentID\" IN (" . implode(', ', $ids) . ") - ORDER BY \"Year\" DESC, \"Month\" DESC;" + AS Month, + $yearclause AS Year + FROM SiteTree$suffix INNER JOIN BlogEntry$suffix + ON SiteTree$suffix.ID = BlogEntry$suffix.ID + WHERE SiteTree$suffix.ParentID IN (" . implode(', ', $ids) . ") + ORDER BY Year DESC, Month DESC;" ); } else { $sqlResults = DB::query(" - SELECT DISTINCT $yearclause AS \"Year\" - FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" - ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\" - WHERE \"ParentID\" IN (" . implode(', ', $ids) . ") - ORDER BY \"Year\" DESC" + SELECT DISTINCT $yearclause AS Year + FROM SiteTree$suffix INNER JOIN BlogEntry$suffix + ON SiteTree$suffix.ID = BlogEntry$suffix.ID + WHERE SiteTree$suffix.ParentID IN (" . implode(', ', $ids) . ") + ORDER BY Year DESC" ); }