View Single Post
  #1  
Old 11-21-2011, 02:27 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I were doing this I would select a batch and loop through it using php to manipulate the strings and then update one at a time in the loop. It would be slow but I'd rather have slow and predictable than fast and unpredictable. You could also check what's going on before running it with the update query and be sure you aren't messing up. If the whole process takes an hour to run, so be it.

--------------- Added [DATE]1321890191[/DATE] at [TIME]1321890191[/TIME] ---------------

First I would use a SELECT That uses LIKE to match the membergroupid.

I would use this php in a loop. If everything looks OK then replace the echo with an update

PHP Code:
$m $membergroupids;
$m ',' $m ',';
$m str_replace(',2,'','$m);
$m substr($m1, -1);
echo 
$membergroupids '  --------------->  ' $m '<br>'
--------------- Added [DATE]1321914118[/DATE] at [TIME]1321914118[/TIME] ---------------

Here's the first thing I would do. Use this for a plugin in showthread_start. All it does is check that the string manipulation is working exactly as it should. You should have a white page with 10 lines each showing user name, primary usergroup, original secondary usergoup string and finally the modified secondary user group string. Edit in your userid in the first line where it says '1'

PHP Code:

if($vbulletin->userinfo['userid'] == '1'
{
    
ini_set('display_errors''1');
    
$users $db->query_read(
        SELECT usergroupid, username, membergroupids 
        FROM " 
TABLE_PREFIX "user 
        WHERE usergroupid <> '6'
        AND CONCAT(',', membergroupids, ',') LIKE CONCAT(',', usergroupid, ',')
        LIMIT 10 
        "
); 
    
    if (
$db->num_rows($users) > 0
    { 
        while(
$user $db->fetch_array($users)) 
        {
            
$n $user['username'];
            
$u $user['usergroupid'];
            
$m1 $user['membergroupids'];
            
$m2 ',' $m1 ',';
            
$find ',' $u ',';
            
$m2 str_replace($find','$m2);
            
$m2 substr($m21, -1);
            echo 
$n ' ; ' .$u ' ; ' $m1 ' -----> '$m2 '<br><br>';
        }
        die(
$db->num_rows($user) . " found");
    }
    else
    {
        die(
"no users found");
    }

If it's working perfectly I'll write a new one with an UPDATE query
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01165 seconds
  • Memory Usage 1,795KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete