MINOR: substituted proprietary SQL datetime operation

This commit is contained in:
Andreas Piening 2010-02-01 05:27:18 +00:00
parent 05bc46acac
commit aa32a6a55d

View File

@ -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();