Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2002, 04:43 PM
Raptor Raptor is offline
 
Join Date: Nov 2001
Posts: 499
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Userfield messed up ?? heres the fix

AFter a lot of pruing etc i found that my USER table had 33799 rows but my userfield table ahd 134,786 rows. Now we had deleted 3 years worth of zero posters to get these figures - but what about the bloated userfield db ?

i'm sure VB should have prined this up auto - well if it does it didnt in this case - and i doubt it could do it faster than this script.

The script checks that the userid in userfield table exists in user table. If it doesnt it deletes it.

After 30 seconds I have 33799 User and 33799 userfield

heres the code - maybe of some use to someone ?

PHP Code:
<?php

$link 
mysql_connect("dbserver""database""password");
mysql_select_db("dforums");

set_time_limit(300000000);

$foundresult mysql_query("select * from userfield order by userid asc");
$foundnum mysql_num_rows($foundresult);

echo(
"Deleting obsolete UserID entries from userfield...<br>\r\n");

for (
$i=0;$i<$foundnum;$i++)
{
    
$row mysql_fetch_array($foundresult);
    
$huntId $row["userid"];
    
    
// now lookup user
    
$huntresult mysql_query("select * from user where userid='$huntId'");
    
$huntnum mysql_num_rows($huntresult);
    
    if (
$huntnum == 0)
    {
        echo(
"Deleting: $huntId<br>\r\n");
        
mysql_query("delete from userfield where userid='$huntId'");
    }
}

mysql_close();
?>
Reply With Quote
  #2  
Old 12-05-2002, 07:15 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm, looks good so
(i have deletet out your dbname and password btw)

just, a question: are you sure you haven't messed up your admin/user.php

normally the entries in userfield are deleted:
PHP Code:
  $DB_site->query("DELETE FROM user WHERE userid='$userid'");
  
$DB_site->query("DELETE FROM userfield WHERE userid='$userid'"); 
Reply With Quote
  #3  
Old 12-06-2002, 02:23 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You may need to repair your userfield table.
Reply With Quote
  #4  
Old 01-23-2003, 01:37 PM
Mutt's Avatar
Mutt Mutt is offline
 
Join Date: Nov 2001
Posts: 331
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had the opposite problem. I had missing userfield entries that needed to be added and it was messing up the admin "search for user" form. I would get no results when searching for a member who didn't have a userfield entry. I made a couple small changes to your script and it worked great. Thanks

PHP Code:
<?php

$link 
mysql_connect("servername""dbusername""dbpassword");
mysql_select_db("dbname");

set_time_limit(300000000);

$foundresult mysql_query("select * from user order by userid asc");
$foundnum mysql_num_rows($foundresult);

echo(
"Adding missing UserID entries to userfield...<br>\r\n");

for (
$i=0;$i<$foundnum;$i++)
{
    
$row mysql_fetch_array($foundresult);
    
$huntId $row["userid"];
    
    
// now lookup user
    
$huntresult mysql_query("select * from userfield where userid='$huntId'");
    
$huntnum mysql_num_rows($huntresult);
    
    if (
$huntnum == 0)
    {
        echo(
"Adding: $huntId<br>\r\n");
        
mysql_query("INSERT INTO userfield (userid) VALUES ($huntId)");
    }
}

echo(
"Finshed<br>\r\n");


mysql_close();
?>
it checks the user table and then looks for a userfield entry, if one isn't found it makes one.

make sure to change servername, dbusername, dbpassword, & dbname to your settings.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:03 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04169 seconds
  • Memory Usage 2,205KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete