From 01de0a76d6875f9ea1ce48a23b9b1a61df548357 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 8 May 2014 10:54:32 +0100 Subject: [PATCH 1/2] Update ArchiveWidget.php --- code/widgets/ArchiveWidget.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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" ); } From 04d2150dc80dfb9ecb83ecd3a962ab3edfbf6778 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 12 May 2014 09:19:55 +0100 Subject: [PATCH 2/2] Update ArchiveWidget.php --- code/widgets/ArchiveWidget.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php index a82ad5d..24c0903 100644 --- a/code/widgets/ArchiveWidget.php +++ b/code/widgets/ArchiveWidget.php @@ -65,26 +65,27 @@ if(class_exists('Widget')) { $yearclause = 'YEAR("Date")'; } + // Changed the WHERE clause from where ParentID to WHERE SiteTree$suffix.ParentID as it was ambiguous. + 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 SiteTree$suffix.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 SiteTree$suffix.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" ); } - if($sqlResults) foreach($sqlResults as $sqlResult) { $isMonthDisplay = $this->DisplayMode == 'month';