I want to write a query that will delete all threads that were either closed or moved over a month ago. Here is what I have come up with: <br /> <br />
#258570 - 04/15/0404:46 PMRe: Useful MySQL Queries for UBB.Threads
[Re: eslmix]
scroungr
Old Hand
Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
Question.. whatif there is a poll in one of those posts.. won't that mess up the poll tables?
_________________________
Couchtomatoe - www.couch-tomatoe.cc My abilities are for hire for installs, upgrades, custom themes and custom modifications.
So I guess I'd have to make a script out of it then, so it can look for polls and purge the corresponding tables? But without that, it would just leave orphaned tables though, right? No harm but taking up space, right?
#258572 - 04/15/0410:08 PMRe: Useful MySQL Queries for UBB.Threads
[Re: eslmix]
JoshPet
I type Like navaho
Registered: 11/29/01
Posts: 11330
Loc: Charlotte, NC
Yeah, I wouldn't manually delete posts - there are several other things which need adjusting and mismatched post counts to board totals and post totals are exactly what cause that blank page issue you have from time to time.<br /><br />Study the scripts which expire or delete the threads - and you'll see the stuff that needs to be deleted as well.<br /><br />Off the top of my head:<br /><br />- Adjust the post/thread count in the boards table.<br />- Any users who have those threads as their favorites<br />- Anybody with post reminders to those threads<br />- Polls, their options and results attached to those posts<br />- File attached to those posts<br /><br />You don't want all that stuff to get out of sync.<br />There might be more - just thinking out loud.
Has anyone ever written a script to automate adding new users or adding a long list of users in one fell swoop? <br /><br />We've got a bunch of users from a newsgroup and would like to move the entire group to ubb.threads but adding users one by one is drudgery.<br /><br />Seems like it'd be possible to figure out by analyzing the addusers.php file line by line but just wondering if anyone's tried it.
#258575 - 04/17/0410:20 PMRe: Useful MySQL Queries for UBB.Threads
[Re: Arash]
scroungr
Old Hand
Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
You could add the users and give them all the same generic password which they could then change using an INSERT but all the other options that basically get entered also would suffer the same fate as the password. Easier to setup the board and let the user himself register himself.
_________________________
Couchtomatoe - www.couch-tomatoe.cc My abilities are for hire for installs, upgrades, custom themes and custom modifications.
We'd like to keep the board ultra-secure/private so I've deleted the New User button and am being the doorman.<br /><br />We've already got old user info/password hashes in mysql, and would like to just transfer this old mysql database to ubb.threads. <br /><br />Seems like there's a lot more involved than just the w3t_users table when creating new users though. If anybody's got any idea of the web of chain mysql reactions that goes into creating a new user, please give a honk. <img src="http://www.ubbdev.com/forum/images/graemlins/rainbow.gif" alt="" />
#258577 - 04/19/0408:10 AMRe: Useful MySQL Queries for UBB.Threads
[Re: Arash]
scroungr
Old Hand
Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
Just take a look at Adduser.php its all there <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" />
_________________________
Couchtomatoe - www.couch-tomatoe.cc My abilities are for hire for installs, upgrades, custom themes and custom modifications.
_________________________
Couchtomatoe - www.couch-tomatoe.cc My abilities are for hire for installs, upgrades, custom themes and custom modifications.
Wow, that mod rocks and does most of the job.<br /><br />Thanks scroungr!<br /><br /> <img src="http://www.ubbdev.com/forum/images/graemlins/thankyousign.gif" alt="" />
Here is one I need help with. I did some major group re-structuring last week, and a few dozen people (maybe more) are now not part of any group, not even the default "Users" <img src="http://www.ubbdev.com/forum/images/graemlins/blush.gif" alt="" /><br /><br />This causes them to get mysql errors when trying to browse the forums, since they aren't in a group so they get weird errors. <br /><br />I want a query to find these users who do not have a group assigned so I can fix their accounts. And even better, another query to automatically search for someone without a group, and if they don't have one they are assigned to the Users group.
Select * from w3t_Users where U_Groups = "" or U_Groups is NULL or U_Groups = "--"<br /><br />That should grab all users with empty groups. The last one shouldn't be necessary.
_________________________
Running a community? -> Keep informed and take it to the next level
#258582 - 05/01/0410:05 PMRe: Useful MySQL Queries for UBB.Threads
[Re: -Fusion-]
scroungr
Old Hand
Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
yeah then do an <br /><br />UPDATE w3t_Users SET U_Groups = "-4-" WHERE U_Groups = "" or U_Groups is NULL or U_Groups = "--"
_________________________
Couchtomatoe - www.couch-tomatoe.cc My abilities are for hire for installs, upgrades, custom themes and custom modifications.
TOP posters from any forum (here 'hp') <br /><br />SELECT t1.B_PosterId,t2.U_Username,count(*) AS liczba <br />FROM w3t_Posts AS t1,w3t_Users AS t2 <br />WHERE t1.B_PosterId = t2.U_Number <br />AND t1.B_Board = "hp" <br />GROUP BY t1.B_PosterId <br />ORDER BY liczba desc