Browse Source

Merge pull request #884 from Arantor/release-2.1

! Upgrading verification questions should really use db_insert which dea...
Arantor 11 years ago
parent
commit
697a1a7bc2
3 changed files with 21 additions and 30 deletions
  1. 7 8
      other/upgrade_2-1_mysql.sql
  2. 7 11
      other/upgrade_2-1_postgresql.sql
  3. 7 11
      other/upgrade_2-1_sqlite.sql

+ 7 - 8
other/upgrade_2-1_mysql.sql

@@ -484,19 +484,18 @@ $get_questions = upgrade_query("
 	WHERE comment_type = 'ver_test'");
 
 	while ($row = $smcFunc['db_fetch_assoc']($get_questions))
-	{
-		$questions[] = "($language, $row[question], serialize(array($row[answer])))";
-	}
+		$questions[] = array($language, $row['question'], serialize(array($row['answer'])));
 
 	$smcFunc['db_free_result']($get_questions);
 
 	if (!empty($questions))
 	{
-		upgrade_query("
-			INSERT INTO {$db_prefix}qanda
-				(lngfile, question, answers)
-			VALUES
-				" . implode(',', $questions));
+		$smcFunc['db_insert']('',
+			'{db_prefix}qanda',
+			array('lngfile' => 'string', 'question' => 'string', 'answers' => 'string'),
+			$questions,
+			array('id_question')
+		);
 
 		// Delete the questions from log_comments now
 		upgrade_query("

+ 7 - 11
other/upgrade_2-1_postgresql.sql

@@ -548,22 +548,18 @@ CREATE TABLE {$db_prefix}qanda (
 		WHERE comment_type = 'ver_test'");
 
 	while ($row = $smcFunc['db_fetch_assoc']($get_questions))
-	{
-		$questions[] = "($language, $row[question], serialize(array($row[answer])))";
-	}
+		$questions[] = array($language, $row['question'], serialize(array($row['answer'])));
 
 	$smcFunc['db_free_result']($get_questions);
 
 	if (!empty($questions))
 	{
-		foreach ($questions as $question)
-		{
-			upgrade_query("
-				INSERT INTO {$db_prefix}qanda
-					(lngfile, question, answers)
-				VALUES
-					" . $question);
-		}
+		$smcFunc['db_insert']('',
+			'{db_prefix}qanda',
+			array('lngfile' => 'string', 'question' => 'string', 'answers' => 'string'),
+			$questions,
+			array('id_question')
+		);
 
 		// Delete the questions from log_comments now
 		upgrade_query("

+ 7 - 11
other/upgrade_2-1_sqlite.sql

@@ -538,22 +538,18 @@ CREATE TABLE IF NOT EXISTS {$db_prefix}qanda (
 		WHERE comment_type = 'ver_test'");
 
 	while ($row = $smcFunc['db_fetch_assoc']($get_questions))
-	{
-		$questions[] = "($language, $row[question], serialize(array($row[answer])))";
-	}
+		$questions[] = array($language, $row['question'], serialize(array($row['answer'])));
 
 	$smcFunc['db_free_result']($get_questions);
 
 	if (!empty($questions))
 	{
-		foreach ($questions as $question)
-		{
-			upgrade_query("
-				INSERT INTO {$db_prefix}qanda
-					(lngfile, question, answers)
-				VALUES
-					" . $question);
-		}
+		$smcFunc['db_insert']('',
+			'{db_prefix}qanda',
+			array('lngfile' => 'string', 'question' => 'string', 'answers' => 'string'),
+			$questions,
+			array('id_question')
+		);
 
 		// Delete the questions from log_comments now
 		upgrade_query("