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
@ -159,14 +159,22 @@ class BlogTree extends Page {
|
|||||||
if(strpos($date, '-')) {
|
if(strpos($date, '-')) {
|
||||||
$year = (int) substr($date, 0, strpos($date, '-'));
|
$year = (int) substr($date, 0, strpos($date, '-'));
|
||||||
$month = (int) substr($date, strpos($date, '-') + 1);
|
$month = (int) substr($date, strpos($date, '-') + 1);
|
||||||
|
|
||||||
if($year && $month) {
|
if($year && $month) {
|
||||||
$dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
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 {
|
} else {
|
||||||
$year = (int) $date;
|
$year = (int) $date;
|
||||||
if($year) {
|
if($year) {
|
||||||
$dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
|
||||||
|
$dateCheck = "AND " . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%Y') . " = '$year'";
|
||||||
|
} else {
|
||||||
|
$dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user