Skip to content

Commit

Permalink
Merge pull request #121 from MichaelCSLWeb/master
Browse files Browse the repository at this point in the history
Update ArchiveWidget.php
  • Loading branch information
Damian Mooyman committed Mar 5, 2015
2 parents 0e267db + 04d2150 commit 09a297d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions code/widgets/ArchiveWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,27 @@ function getDates() {
$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 \"ParentID\" IN (" . implode(', ', $ids) . ")
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) . ")
WHERE \"SiteTree$suffix\".\"ParentID\" IN (" . implode(', ', $ids) . ")
ORDER BY \"Year\" DESC"
);
}

if($sqlResults) foreach($sqlResults as $sqlResult) {
$isMonthDisplay = $this->DisplayMode == 'month';

Expand Down

0 comments on commit 09a297d

Please sign in to comment.