Created
July 8, 2011 22:57
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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