mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
MINOR: substituted proprietary SQL datetime operation
This commit is contained in:
parent
05bc46acac
commit
aa32a6a55d
@ -161,15 +161,23 @@ class BlogTree extends Page {
|
||||
$month = (int) substr($date, strpos($date, '-') + 1);
|
||||
|
||||
if($year && $month) {
|
||||
if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
|
||||
$dateCheck = 'AND ' . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%m') . " * 1 = $month AND " . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%Y') . " = '$year'";
|
||||
} else {
|
||||
$dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$year = (int) $date;
|
||||
if($year) {
|
||||
if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
|
||||
$dateCheck = "AND " . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%Y') . " = '$year'";
|
||||
} else {
|
||||
$dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build a list of all IDs for BlogHolders that are children of us
|
||||
$holderIDs = $this->BlogHolderIDs();
|
||||
|
Loading…
Reference in New Issue
Block a user