Update ArchiveWidget.php

This commit is contained in:
Michael 2014-05-12 09:19:55 +01:00
parent 01de0a76d6
commit 04d2150dc8

View File

@ -65,26 +65,27 @@ if(class_exists('Widget')) {
$yearclause = 'YEAR("Date")'; $yearclause = 'YEAR("Date")';
} }
// Changed the WHERE clause from where ParentID to WHERE SiteTree$suffix.ParentID as it was ambiguous.
if($this->DisplayMode == 'month') { if($this->DisplayMode == 'month') {
$sqlResults = DB::query(" $sqlResults = DB::query("
SELECT DISTINCT CAST($monthclause AS " . DB::getConn()->dbDataType('unsigned integer') . ") SELECT DISTINCT CAST($monthclause AS " . DB::getConn()->dbDataType('unsigned integer') . ")
AS Month, AS \"Month\",
$yearclause AS Year $yearclause AS \"Year\"
FROM SiteTree$suffix INNER JOIN BlogEntry$suffix FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\"
ON SiteTree$suffix.ID = BlogEntry$suffix.ID ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
WHERE SiteTree$suffix.ParentID IN (" . implode(', ', $ids) . ") WHERE \"SiteTree$suffix\".\"ParentID\" IN (" . implode(', ', $ids) . ")
ORDER BY Year DESC, Month DESC;" ORDER BY \"Year\" DESC, \"Month\" DESC;"
); );
} else { } else {
$sqlResults = DB::query(" $sqlResults = DB::query("
SELECT DISTINCT $yearclause AS Year SELECT DISTINCT $yearclause AS \"Year\"
FROM SiteTree$suffix INNER JOIN BlogEntry$suffix FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\"
ON SiteTree$suffix.ID = BlogEntry$suffix.ID ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
WHERE SiteTree$suffix.ParentID IN (" . implode(', ', $ids) . ") WHERE \"SiteTree$suffix\".\"ParentID\" IN (" . implode(', ', $ids) . ")
ORDER BY Year DESC" ORDER BY \"Year\" DESC"
); );
} }
if($sqlResults) foreach($sqlResults as $sqlResult) { if($sqlResults) foreach($sqlResults as $sqlResult) {
$isMonthDisplay = $this->DisplayMode == 'month'; $isMonthDisplay = $this->DisplayMode == 'month';