FIX BlogArchiveWidget for PostgreSQL compatibility

This commit is contained in:
Robbie Averill 2017-09-26 17:17:53 +13:00
parent 92f6192870
commit 8e684dea50

View File

@ -92,15 +92,15 @@ class BlogArchiveWidget extends Widget
$publishDate = DB::get_conn()->formattedDatetimeClause('"PublishDate"', $format); $publishDate = DB::get_conn()->formattedDatetimeClause('"PublishDate"', $format);
$fields = array( $fields = array(
'PublishDate' => $publishDate, 'PublishDate' => $publishDate,
'Total' => "Count('PublishDate')" 'Total' => "COUNT('\"PublishDate\"')"
); );
$stage = Versioned::current_stage(); $stage = Versioned::current_stage();
$suffix = ($stage === 'Live') ? '_Live' : ''; $suffix = ($stage === 'Live') ? '_Live' : '';
$query = SQLSelect::create($fields, "BlogPost{$suffix}") $query = SQLSelect::create($fields, '"BlogPost' . $suffix . '"')
->addGroupBy($publishDate) ->addGroupBy($publishDate)
->addOrderBy('PublishDate Desc') ->addOrderBy('"PublishDate" DESC')
->addWhere(array('PublishDate < ?' => SS_Datetime::now()->Format('Y-m-d'))); ->addWhere(array('"PublishDate" < ?' => SS_Datetime::now()->Format('Y-m-d')));
$posts = $query->execute(); $posts = $query->execute();
$result = new ArrayList(); $result = new ArrayList();