Skip to content

Instantly share code, notes, and snippets.

@Quilted
Created July 8, 2011 22:57
Show Gist options
  • Save Quilted/1073030 to your computer and use it in GitHub Desktop.
Save Quilted/1073030 to your computer and use it in GitHub Desktop.
D6: Update a single db value for all users based on a regex
$result = db_query("SELECT uid FROM {users}");
while ($row = db_fetch_object($result)) {
$user = user_load($row->uid);
$new_state_profile = preg_replace('/^(\S){2}\s/', '', $user->profile_state);
update_sql("UPDATE {profile_values} SET value = '$new_state_profile' WHERE uid = $user->uid AND fid = 6");
}
// Clear caches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment