Skip to content

Commit

Permalink
Fixed issue: High memory usage on db upgrade from older versions
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Sep 19, 2014
1 parent 90ee6f0 commit f3e245c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -1282,21 +1282,24 @@ function upgradeSurveys177()
{
$sSurveyQuery = "SELECT surveyls_attributecaptions,surveyls_survey_id,surveyls_language FROM {{surveys_languagesettings}}";
$oSurveyResult = Yii::app()->db->createCommand($sSurveyQuery)->queryAll();
$sSurveyLSUpdateQuery= "update {{surveys_languagesettings}} set surveyls_attributecaptions=:attributecaptions where surveyls_survey_id=".$aSurveyRow['surveyls_survey_id'].' and surveyls_language=:language';
$sSurveyLSUpdateQuery= "update {{surveys_languagesettings}} set surveyls_attributecaptions=:attributecaptions where surveyls_survey_id=:surveyid and surveyls_language=:language";
foreach ( $oSurveyResult as $aSurveyRow )
{
$aAttributeDescriptions=@unserialize($aSurveyRow['surveyls_attributecaptions']);
if (!$aAttributeDescriptions) $aAttributeDescriptions=array();
Yii::app()->db->createCommand($sSurveyLSUpdateQuery)->execute(array(':language'=>$aSurveyRow['surveyls_language'],':attributecaptions'=>json_encode($aAttributeDescriptions)));
Yii::app()->db->createCommand($sSurveyLSUpdateQuery)->execute(
array(':language'=>$aSurveyRow['surveyls_language'],
':surveyid'=>$aSurveyRow['surveyls_survey_id'],
':attributecaptions'=>json_encode($aAttributeDescriptions)));
}
$sSurveyQuery = "SELECT sid FROM {{surveys}}";
$oSurveyResult = Yii::app()->db->createCommand($sSurveyQuery)->queryAll();
$sSurveyUpdateQuery= "update {{surveys}} set attributedescriptions=:attributedescriptions where sid=".$aSurveyRow['sid'];
$sSurveyUpdateQuery= "update {{surveys}} set attributedescriptions=:attributedescriptions where sid=:surveyid";
foreach ( $oSurveyResult as $aSurveyRow )
{
$aAttributeDescriptions=@unserialize($aSurveyRow['attributedescriptions']);
if (!$aAttributeDescriptions) $aAttributeDescriptions=array();
Yii::app()->db->createCommand($sSurveyUpdateQuery)->execute(array(':attributedescriptions'=>json_encode($aAttributeDescriptions)));
Yii::app()->db->createCommand($sSurveyUpdateQuery)->execute(array(':attributedescriptions'=>json_encode($aAttributeDescriptions),':surveyid'=>$aSurveyRow['sid']));
}
}

Expand Down

0 comments on commit f3e245c

Please sign in to comment.