Skip to content

Commit

Permalink
FIX BlogArchiveWidget for PostgreSQL compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Sep 26, 2017
1 parent 92f6192 commit 8e684de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code/widgets/BlogArchiveWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ public function getArchive()
$publishDate = DB::get_conn()->formattedDatetimeClause('"PublishDate"', $format);
$fields = array(
'PublishDate' => $publishDate,
'Total' => "Count('PublishDate')"
'Total' => "COUNT('\"PublishDate\"')"
);

$stage = Versioned::current_stage();
$suffix = ($stage === 'Live') ? '_Live' : '';
$query = SQLSelect::create($fields, "BlogPost{$suffix}")
$query = SQLSelect::create($fields, '"BlogPost' . $suffix . '"')
->addGroupBy($publishDate)
->addOrderBy('PublishDate Desc')
->addWhere(array('PublishDate < ?' => SS_Datetime::now()->Format('Y-m-d')));
->addOrderBy('"PublishDate" DESC')
->addWhere(array('"PublishDate" < ?' => SS_Datetime::now()->Format('Y-m-d')));

$posts = $query->execute();
$result = new ArrayList();
Expand Down

0 comments on commit 8e684de

Please sign in to comment.