From 2961a00b469d5faaa66b78913370c10fe62fe199 Mon Sep 17 00:00:00 2001 From: Geoff Munn Date: Thu, 12 Mar 2009 21:48:58 +0000 Subject: [PATCH] BUG FIX: SQL queries fixed for MSSQL git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@72983 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CommentAdmin.php | 8 ++++---- code/sitefeatures/PageCommentInterface.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/CommentAdmin.php b/code/CommentAdmin.php index 2e46f6ea..7a998d67 100644 --- a/code/CommentAdmin.php +++ b/code/CommentAdmin.php @@ -55,7 +55,7 @@ class CommentAdmin extends LeftAndMain { $section = $this->Section(); if($section == 'approved') { - $filter = 'NOT "IsSpam" AND NOT "NeedsModeration"'; + $filter = "\"IsSpam\"=0 AND \"NeedsModeration\"=0"; $title = "

". _t('CommentAdmin.APPROVEDCOMMENTS', 'Approved Comments')."

"; } else if($section == 'unmoderated') { $filter = '"NeedsModeration"'; @@ -272,21 +272,21 @@ JS; * Return the number of moderated comments */ function NumModerated() { - return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE NOT \"IsSpam\" AND NOT \"NeedsModeration\"")->value(); + return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"IsSpam\"=0 AND \"NeedsModeration\"=0")->value(); } /** * Return the number of unmoderated comments */ function NumUnmoderated() { - return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE NOT \"IsSpam\" AND \"NeedsModeration\"")->value(); + return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"IsSpam\"=0 AND \"NeedsModeration\"=0")->value(); } /** * Return the number of comments marked as spam */ function NumSpam() { - return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"IsSpam\"")->value(); + return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"IsSpam\"=1")->value(); } } diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index f60c5d26..dc7f24ef 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -189,8 +189,8 @@ class PageCommentInterface extends RequestHandler { $limit['start'] = isset($_GET['commentStart']) ? (int)$_GET['commentStart'] : 0; $limit['limit'] = PageComment::$comments_per_page; - $spamfilter = isset($_GET['showspam']) ? '' : 'AND NOT "IsSpam"'; - $unmoderatedfilter = Permission::check('ADMIN') ? '' : 'AND NOT "NeedsModeration"'; + $spamfilter = isset($_GET['showspam']) ? '' : "AND \"IsSpam\"=0"; + $unmoderatedfilter = Permission::check('ADMIN') ? '' : "AND \"NeedsModeration\"=0"; $comments = DataObject::get("PageComment", "\"ParentID\" = '" . Convert::raw2sql($this->page->ID) . "' $spamfilter $unmoderatedfilter", '"Created" DESC', "", $limit); if(is_null($comments)) {