Skip to content

Commit

Permalink
Fixed issue SQL error on load (bug related to commit/revision 12153)
Browse files Browse the repository at this point in the history
Dev bad DELETE syntax

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12167 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Jan 23, 2012
1 parent e1e9d18 commit 5e9cf64
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -181,6 +181,9 @@ public static function SetEMLanguage($lang=NULL)
public static function UpgradeConditionsToRelevance($surveyId=NULL, $qid=NULL)
{
LimeExpressionManager::SetDirtyFlag(); // set dirty flag even if not conditions, since must have had a DB change
// Cheat and upgrade question attributes here too.
self::UpgradeQuestionAttributes(true,$surveyId,$qid);

$releqns = self::ConvertConditionsToRelevance($surveyId,$qid);
$num = count($releqns);
if ($num == 0) {
Expand All @@ -193,8 +196,6 @@ public static function UpgradeConditionsToRelevance($surveyId=NULL, $qid=NULL)
dbExecuteAssoc($query);
$queries[] = $query;
}
// Cheat and upgrade question attributes here too.
$queries = array_merge($queries, self::UpgradeQuestionAttributes(true,$surveyId,$qid));
LimeExpressionManager::SetDirtyFlag();
return $queries;
}
Expand Down Expand Up @@ -5314,6 +5315,8 @@ public static function UpgradeQuestionAttributes($changeDB=false,$surveyid=NULL,
'min_num_value_sgqa' => 'min_num_value',
'num_value_equals_sgqa' => 'equals_num_value',
);
$reverseAttributeMap = array_flip($attibutemap);

foreach ($qattrs as $qid => $qattr)
{
$updates = array();
Expand All @@ -5337,28 +5340,11 @@ public static function UpgradeQuestionAttributes($changeDB=false,$surveyid=NULL,
foreach ($updates as $key=>$value)
{
$query = "UPDATE {{question_attributes}} SET value='".addslashes($value)."' WHERE qid=".$qid." and attribute='".addslashes($key)."';";
$queries[] = $query;
}
}
foreach ($attibutemap as $key=>$value)
{
$query = "DELETE FROM {{question_attributes}}";
if (!is_null($surveyid))
{
$query .= ", {{questions}}";
}
$query .= " WHERE {{question_attributes}}.attribute='" . $key . "'";
if (!is_null($onlythisqid))
{
$query .= " AND {{question_attributes}}.qid=".$onlythisqid;
}
else if (!is_null($surveyid))
{
$query .= " AND {{question_attributes}}.qid = {{questions}}.qid";
$query .= " AND {{questions}}.sid=".$surveyid;
$queries[] = $query;
$query = "DELETE FROM {{question_attributes}} WHERE qid=".$qid." and attribute='".addslashes($reverseAttributeMap[$key])."';";
$queries[] = $query;

}
$query .= ";";
$queries[] = $query;
}
// now update the datbase
foreach ($queries as $query)
Expand Down

0 comments on commit 5e9cf64

Please sign in to comment.