From 2ce25899ea9ddb3f0c42326f5851b84088d8c91d Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Fri, 11 Dec 2009 10:38:46 +0000 Subject: [PATCH] Fixed issue #3973: Statistics fails on Multi Flexi question type on MSSQL DB git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@8142 b72ed6b6-b9f8-46b5-92b4-906544132732 --- admin/statistics_function.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/admin/statistics_function.php b/admin/statistics_function.php index b52a27b18c6..c2651480652 100644 --- a/admin/statistics_function.php +++ b/admin/statistics_function.php @@ -1778,7 +1778,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, break; } - + echo ''; //loop thorugh the array which contains all answer data foreach ($alist as $al) { @@ -1858,9 +1858,17 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, // ==> value is '' // * NoAnswer due to conditions, or a page not displayed // ==> value is NULL - $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($rt)." IS NULL " - . "OR ".db_quote_id($rt)." = '' " - . "OR ".db_quote_id($rt)." = ' '"; + if ($connect->databaseType == 'odbc_mssql' || $connect->databaseType == 'odbtp' || $connect->databaseType == 'mssql_n') + { + // mssql cannot compare text blobs so we have to cast here + $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($rt)." IS NULL " + . "OR cast(".db_quote_id($rt)." as varchar) = '' " + . "OR cast(".db_quote_id($rt)." as varchar) = ' '"; + } + else + $query = "SELECT count(*) FROM ".db_table_name("survey_$surveyid")." WHERE ".db_quote_id($rt)." IS NULL " + . "OR ".db_quote_id($rt)." = '' " + . "OR ".db_quote_id($rt)." = ' '"; } }