Rewrite
authorRoland Häder <roland@mxchange.org>
Mon, 4 Jul 2011 01:35:23 +0000 (01:35 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 4 Jul 2011 01:35:23 +0000 (01:35 +0000)
inc/fix_user_points.php

index bcb648ced491125b4c8b075f856c7b46bdde45fd..d7d16223561632ff604c5ed6eeb5c94d8ebfd629 100644 (file)
@@ -42,7 +42,11 @@ if (!defined('__SECURITY')) {
 
 // Get all user points
 $result = SQL_QUERY('SELECT
-       `userid`, `points`
+       `userid`,
+       `points`,
+       `locked_points`,
+       `order_points`,
+       `locked_order_points`
 FROM
        `{?_MYSQL_PREFIX?}_user_points`
 WHERE
@@ -54,8 +58,20 @@ ORDER BY
 if (!SQL_HASZERONUMS($result)) {
        // Load row by row
        while ($row = SQL_FETCHARRAY($result)) {
-               // We have to fix this amount, so first pay it directly
-               addPointsDirectly('user_null_fix', $row['userid'], $row['points']);
+               // Update the database again
+               foreach (array_keys($row) as $column) {
+                       // Not userid itself
+                       if ($column != 'userid') {
+                               // Update amount
+                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `%s`=`%s`+%s WHERE `userid`=%s AND `ref_depth` IS NULL",
+                                       array(
+                                               $column,
+                                               $column,
+                                               $row[$column],
+                                               $row['userid']
+                                       ), __FILE__, __LINE__);
+                       } // END - if
+               } // END - foreach
        } // END - while
 } // END - if