mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
BUG FIX: month calculation system fixed to be database-agnostic
This commit is contained in:
parent
3198619d0b
commit
c23b49323f
@ -55,11 +55,12 @@ class ArchiveWidget extends Widget {
|
||||
$stage = Versioned::current_stage();
|
||||
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
|
||||
|
||||
$monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') . ' * 1' : 'MONTH("Date")';
|
||||
$yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
|
||||
$monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")';
|
||||
$yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
|
||||
|
||||
if($this->DisplayMode == 'month') {
|
||||
$sqlResults = DB::query("
|
||||
SELECT DISTINCT $monthclause AS \"Month\", $yearclause AS \"Year\"
|
||||
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;"
|
||||
|
Loading…
Reference in New Issue
Block a user