Jelajahi Sumber

Fix a typo in updating the old cust fields order

Signed-off-by: Suki <[email protected]>
Suki 10 tahun lalu
induk
melakukan
abe7e4972a
3 mengubah file dengan 52 tambahan dan 25 penghapusan
  1. 18 9
      other/upgrade_2-1_mysql.sql
  2. 17 8
      other/upgrade_2-1_postgresql.sql
  3. 17 8
      other/upgrade_2-1_sqlite.sql

+ 18 - 9
other/upgrade_2-1_mysql.sql

@@ -598,25 +598,34 @@ INSERT INTO `{$db_prefix}custom_fields` (`col_name`, `field_name`, `field_desc`,
 ('cust_gender', 'Gender', 'Your gender.', 'radio', 255, 'Male,Female', 6, 'nohtml', 1, 1, 0, 'forumprofile', 0, 1, 0, 0, 'Male', '<span class=" generic_icons gender_{INPUT}" alt="{INPUT}" title="{INPUT}">', 1);
 ---#
 
----# Add an order value to each existing cust profile field.
+---# Add an order and show on mlist value to each existing cust profile field.
 ---{
-	$old_cust_fields = upgrade_query("
+	$ocf = $smcFunc['db_query']('', '
 		SELECT id_field
-		FROM {$db_prefix}custom_fields");
+		FROM {db_prefix}custom_fields');
 
 		// We start counting from 6 because we already have the first 6 fields.
 		$fields_count = 6;
 
-		while ($row = mysql_fetch_assoc($old_cust_fields))
+		while ($row = $smcFunc['db_fetch_assoc']($ocf))
 		{
 			$fields_count++;
 
-			upgrade_query("
-				UPDATE {$db_prefix}custom_fields
-				SET field_order = $fields_count,
-				WHERE id_attach = $row[id_field]");
+			if (!empty($row['id_field']))
+				$smcFunc['db_query']('', '
+					UPDATE {db_prefix}custom_fields
+					SET field_order = {int:field_count}, show_mlist = {int:show_mlist}
+					WHERE id_field = {int:id_field}
+						AND field_order = {int:show_mlist}',
+					array(
+						'field_count' => $fields_count,
+						'show_list' => 0,
+						'id_field' => $row['id_field'],
+						'six' => 6,
+					)
+				);
 		}
-		$smcFunc['db_free_result']($old_cust_fields);
+		$smcFunc['db_free_result']($ocf);
 ---}
 ---#
 

+ 17 - 8
other/upgrade_2-1_postgresql.sql

@@ -670,23 +670,32 @@ INSERT INTO `{$db_prefix}custom_fields` (`col_name`, `field_name`, `field_desc`,
 
 ---# Add an order value to each existing cust profile field.
 ---{
-	$old_cust_fields = upgrade_query("
+	$ocf = $smcFunc['db_query']('', '
 		SELECT id_field
-		FROM {$db_prefix}custom_fields");
+		FROM {db_prefix}custom_fields');
 
 		// We start counting from 6 because we already have the first 6 fields.
 		$fields_count = 6;
 
-		while ($row = mysql_fetch_assoc($old_cust_fields))
+		while ($row = $smcFunc['db_fetch_assoc']($ocf))
 		{
 			$fields_count++;
 
-			upgrade_query("
-				UPDATE {$db_prefix}custom_fields
-				SET field_order = $fields_count,
-				WHERE id_attach = $row[id_field]");
+			if (!empty($row['id_field']))
+				$smcFunc['db_query']('', '
+					UPDATE {db_prefix}custom_fields
+					SET field_order = {int:field_count}, show_mlist = {int:show_mlist}
+					WHERE id_field = {int:id_field}
+						AND field_order = {int:show_mlist}',
+					array(
+						'field_count' => $fields_count,
+						'show_list' => 0,
+						'id_field' => $row['id_field'],
+						'six' => 6,
+					)
+				);
 		}
-		$smcFunc['db_free_result']($old_cust_fields);
+		$smcFunc['db_free_result']($ocf);
 ---}
 ---#
 

+ 17 - 8
other/upgrade_2-1_sqlite.sql

@@ -666,23 +666,32 @@ INSERT INTO `{$db_prefix}custom_fields` (`col_name`, `field_name`, `field_desc`,
 
 ---# Add an order value to each existing cust profile field.
 ---{
-	$old_cust_fields = upgrade_query("
+	$ocf = $smcFunc['db_query']('', '
 		SELECT id_field
-		FROM {$db_prefix}custom_fields");
+		FROM {db_prefix}custom_fields');
 
 		// We start counting from 6 because we already have the first 6 fields.
 		$fields_count = 6;
 
-		while ($row = mysql_fetch_assoc($old_cust_fields))
+		while ($row = $smcFunc['db_fetch_assoc']($ocf))
 		{
 			$fields_count++;
 
-			upgrade_query("
-				UPDATE {$db_prefix}custom_fields
-				SET field_order = $fields_count,
-				WHERE id_attach = $row[id_field]");
+			if (!empty($row['id_field']))
+				$smcFunc['db_query']('', '
+					UPDATE {db_prefix}custom_fields
+					SET field_order = {int:field_count}, show_mlist = {int:show_mlist}
+					WHERE id_field = {int:id_field}
+						AND field_order = {int:show_mlist}',
+					array(
+						'field_count' => $fields_count,
+						'show_list' => 0,
+						'id_field' => $row['id_field'],
+						'six' => 6,
+					)
+				);
 		}
-		$smcFunc['db_free_result']($old_cust_fields);
+		$smcFunc['db_free_result']($ocf);
 ---}
 ---#