- // 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__);
+
+ // Nothing has been updated?
+ if (SQL_HASZEROAFFECTED()) {
+ // Then insert it
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`,`ref_depth`,`%s`) VALUES (%s,NULL,%s)",
+ array(
+ $column,
+ $row['userid'],
+ $row[$column]
+ ), __FILE__, __LINE__);
+ } // END - if
+ } // END - if
+ } // END - foreach