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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2004, 09:36 PM
restless's Avatar
restless restless is offline
 
Join Date: Jan 2002
Location: Canada
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default querie for deleting private messages by date

when i imported my old database, it messed up and only imported certain things. it DID import private messages, but unfortunately... it DIDN'T import my users.

so... i have a bunch of new users signing up, and for each new user, they find a cache of old pm's in their inbox that belong to whoever had their user id# on the old forum. this is going to keep happening right up through our 4000 and something registrations unless i can figure out how to kill them.

is there a mysql querie i can use to delete pms from before a certain date? this is a very sensitive issue, as there are some fairly private pms in there.

basically, i need to delete all private messages from before December 24, 2003.
Reply With Quote
  #2  
Old 01-13-2004, 09:42 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by restless
when i imported my old database, it messed up and only imported certain things. it DID import private messages, but unfortunately... it DIDN'T import my users.

so... i have a bunch of new users signing up, and for each new user, they find a cache of old pm's in their inbox that belong to whoever had their user id# on the old forum. this is going to keep happening right up through our 4000 and something registrations unless i can figure out how to kill them.

is there a mysql querie i can use to delete pms from before a certain date? this is a very sensitive issue, as there are some fairly private pms in there.

basically, i need to delete all private messages from before December 24, 2003.
you can login and just empty the whole table... altho that wouldnt do for your date solution

why didnt you just rever tot he back up and try to import again?
Reply With Quote
  #3  
Old 01-13-2004, 09:45 PM
restless's Avatar
restless restless is offline
 
Join Date: Jan 2002
Location: Canada
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

my backup was screwed.
Reply With Quote
  #4  
Old 01-13-2004, 09:48 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by restless
my backup was screwed.
then why not just reinstall and start fresh? (just a thought)

im sure someone will come up with a querry to clear all the pm's by date but i know i cant

you COULD just empty the table (not drop it)
Reply With Quote
  #5  
Old 01-13-2004, 09:56 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is easier said then done, due to the 3 PM tables in vB3. You'd need to get the PM's text based on date, then get the pm info for that single one, then delete the PM, PM Text and PM Recipt for that PM and then move onto the next one. I think thats right anyway.
Reply With Quote
  #6  
Old 01-13-2004, 09:59 PM
restless's Avatar
restless restless is offline
 
Join Date: Jan 2002
Location: Canada
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Faranth
then why not just reinstall and start fresh? (just a thought)
hehe... because before i figured out what was going on, i'd already had over 300 users re-register and i've got over 8000 posts. twice in 2 weeks would not have been good.
Reply With Quote
  #7  
Old 01-13-2004, 10:00 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by restless
hehe... because before i figured out what was going on, i'd already had over 300 users re-register and i've got over 8000 posts. twice in 2 weeks would not have been good.
ok good point, i think my idea of emptying the tables seems to be the best idea
Reply With Quote
  #8  
Old 01-15-2004, 09:45 PM
restless's Avatar
restless restless is offline
 
Join Date: Jan 2002
Location: Canada
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i went ahead and did just that.
Reply With Quote
  #9  
Old 01-15-2004, 10:30 PM
restless's Avatar
restless restless is offline
 
Join Date: Jan 2002
Location: Canada
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm... and now i can't get rid of the Private Messages display:

"Private Messages: Unread 1, Total 61"
Reply With Quote
  #10  
Old 01-15-2004, 11:08 PM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Upload this file as pmdelete.php and run it in your browser. Haven't tested it but it should do the trick.

PHP Code:
<?php

error_reporting 
E_ALL & ~E_NOTICE ) ;

require ( 
'./global.php' ) ;

$_dtime mktime 00012242003 ) ;
$getpms $DB_site->query "SELECT pm.pmid AS id,pmtextid AS tid
    FROM " 
TABLE_PREFIX "pm 
    LEFT JOIN " 
TABLE_PREFIX "pmreceipt ON pmreceipt.pmid = pm.pmid
    WHERE pmreceipt.sendtime <= 
$_dtime) ;
while ( 
$pm $DB_site->fetch_array $getpms ) ) :
    
$_idarray[] = $pm['id'] ;
    
$_tidarray[] = $pm['tid'] ;
endwhile ;

$DB_site->query "DELETE FROM " TABLE_PREFIX "pm WHERE pmid IN ( '" implode "', '"$_idarray ) . "' )" ) ;
$DB_site->query "DELETE FROM " TABLE_PREFIX "pmreceipt WHERE pmid IN ( '" implode "', '"$_idarray ) . "' )" ) ;
$DB_site->query "DELETE FROM " TABLE_PREFIX "pmtext WHERE pmtextid IN ( '" implode "', '"$_tidarray ) . "' )" ) ;

echo 
"<p><font face=\"courier\">PM Deletion Completed.</font></p>" ;

?>
Cheers,
g-force2k2
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 09:21 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04845 seconds
  • Memory Usage 2,268KB
  • 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
  • (1)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete