vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Quick SQL question (https://vborg.vbsupport.ru/showthread.php?t=60935)

DarkSavior 01-29-2004 08:58 PM

Quick SQL question
 
Any way to quickly reset an user's info with one SQL command? Like that it restores everything to their default setting.

I need to reset items_user table for specific userid with 1 command to it's default values but don't know how. :(

Would be something like...

PHP Code:

UPDATE items_user SET (what do i put here?) WHERE userid=$bbuserinfo[userid


DarkSavior 02-01-2004 05:39 PM

No idea how to reset a row to default values except the user id? :/

Boofo 02-01-2004 05:45 PM

Couldn't you just use DEFAULT?

g-force2k2 02-01-2004 05:48 PM

I could write you the sql statement, but I know the itemshop works similar to profilefields so in order to reset all of them I would need to know exactly what your sql structure for that table is. If you do a backup for the items_user table to get its structure I will gladly write you the sql.

Cheers,
g-force2k2

DarkSavior 02-01-2004 06:59 PM

1 Attachment(s)
Ok here it is for the current data.

g-force2k2 02-01-2004 07:08 PM

DarkSavior try this code:

PHP Code:

$items $DB_site->query_first "SELECT * FROM items_user WHERE userid=$bbuserinfo['userid']" ) ;

for ( 
$x 0$x <= 50$x++ ) :
    
$item "item" $x ;
    
$points "points" $x ;
    
$desc "description" $x ;
    if ( 
$items["$item"] ) :
        
$update[] = "$item = 'No Item'" ;
    endif ;

    if ( 
$items["$points"] ) :
        
$update[] = "$points = '0'" ;
    endif ;
    
    if ( 
$items["$desc"] ) :
        
$update[] = "$desc = 'No Description Available'" ;
    endif ;
endfor ;

if ( 
sizeof $update ) > ) :
    
$DB_site->query "UPDATE items_user SET " implode ", "$update ) . " WHERE userid=$bbuserinfo[userid]) ;
endif ; 


DarkSavior 02-01-2004 07:22 PM

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\www\forums\member.php on line 1245

Getting that one... Line 1245 is the first line of that code. I just added it after the partial reset add-on.

g-force2k2 02-01-2004 07:30 PM

Try making $bbuserinfo['userid'] just $bbuserinfo[userid]

Regards,
g-force2k2

DarkSavior 02-01-2004 07:33 PM

Ok that one worked. Thanks, gotta add it to reset the Icon too though, but I think I can manage it with this now. :)

Thanks again g-force2k2!

g-force2k2 02-01-2004 07:35 PM

Quote:

Originally Posted by DarkSavior
Ok that one worked. Thanks, gotta add it to reset the Icon too though, but I think I can manage it with this now. :)

Thanks again g-force2k2!

Hey no problem, just make sure after it is reset that it actually reset. Do another download of the sql structure and make sure all the values went back to their defaults. I want to know if the query worked, thanks.

Cheers,
g-force2k2


All times are GMT. The time now is 08:57 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.01252 seconds
  • Memory Usage 1,745KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete