Skip to content

Commit

Permalink
Fixed issue: Various problems when using any MSSQL driver
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@9770 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Feb 11, 2011
1 parent 32a8041 commit 38532cd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion admin/activate_functions.php
Expand Up @@ -292,7 +292,7 @@ function activateSurvey($postsid,$surveyid, $scriptname='admin.php')
foreach ($fieldmap as $arow) //With each question, create the appropriate field(s)
{
if ($createsurvey!='') {$createsurvey .= ",\n";}
$createsurvey .= " ".db_quote_id($arow['fieldname']);
$createsurvey .= ' `'.$arow['fieldname'].'`';
switch($arow['type'])
{
case 'startlanguage':
Expand Down
5 changes: 5 additions & 0 deletions admin/import_functions.php
Expand Up @@ -1305,6 +1305,7 @@ function XMLImportSurvey($sFullFilepath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
$insertdata['help']=translink('survey', $oldsid, $newsid, $insertdata['help']);
if (isset($aQIDReplacements[$oldsqid])){
$insertdata['qid']=$aQIDReplacements[$oldsqid];
db_switchIDInsert('questions',true);
}

$query=$connect->GetInsertSQL($tablename,$insertdata);
Expand All @@ -1314,6 +1315,10 @@ function XMLImportSurvey($sFullFilepath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
{
$aQIDReplacements[$oldsqid]=$newsqid; // add old and new qid to the mapping array
}
else
{
db_switchIDInsert('questions',false);
}
$results['subquestions']++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion classes/dTexts/dFunctions/dFunctionInsertAns.php
Expand Up @@ -10,7 +10,7 @@ public function run($args)
{
global $connect;
$field = $args[0];
$srid = $_SESSION['srid'];
if (isset($_SESSION['srid'])) $srid = $_SESSION['srid'];
$sid = $_POST['sid'];
return retrieve_Answer($field, $_SESSION['dateformats']['phpdate']);
}
Expand Down
11 changes: 9 additions & 2 deletions index.php
Expand Up @@ -2261,7 +2261,7 @@ function submitfailed($errormsg='')
*/
function buildsurveysession()
{
global $thissurvey, $secerror, $clienttoken;
global $thissurvey, $secerror, $clienttoken, $databasetype;
global $tokensexist, $thistpl;
global $surveyid, $dbprefix, $connect;
global $register_errormsg, $clang;
Expand Down Expand Up @@ -2704,7 +2704,14 @@ function buildsurveysession()

// Find all defined randomization groups through question attribute values
$randomGroups=array();
$rgquery = "SELECT attr.qid,value FROM ".db_table_name('question_attributes')." as attr right join ".db_table_name('questions')." as quests on attr.qid=quests.qid WHERE attribute='random_group' and value <> '' and sid=$surveyid GROUP BY attr.qid";
if ($databasetype=='odbc_mssql' || $databasetype=='odbtp' || $databasetype=='mssql_n' || $databasetype=='mssqlnative')
{
$rgquery = "SELECT attr.qid, CAST(value as varchar(255)) FROM ".db_table_name('question_attributes')." as attr right join ".db_table_name('questions')." as quests on attr.qid=quests.qid WHERE attribute='random_group' and CAST(value as varchar(255)) <> '' and sid=$surveyid GROUP BY attr.qid, CAST(value as varchar(255))";
}
else
{
$rgquery = "SELECT attr.qid, value FROM ".db_table_name('question_attributes')." as attr right join ".db_table_name('questions')." as quests on attr.qid=quests.qid WHERE attribute='random_group' and value <> '' and sid=$surveyid GROUP BY attr.qid, value";
}
$rgresult = db_execute_assoc($rgquery);
while($rgrow = $rgresult->FetchRow())
{
Expand Down

0 comments on commit 38532cd

Please sign in to comment.