Is this SQL query ok?

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
s4075051
Registered User
Posts: 11
Joined: Thu May 29, 2008 2:18 pm

Is this SQL query ok?

Post by s4075051 »

I have a big forum with lots of user registrations and customised deletions. Anyway, I'm trying to optimise my SQL space as efficiently as possible so I've added the following command to a cron task:

Code: Select all

$sql_inner = "DELETE g.* FROM phpbb_user_group AS u RIGHT JOIN phpbb_groups AS g ON (g.group_id = u.group_id) WHERE u.user_id IS NULL AND g.group_id > 2";
$db->sql_query($sql_inner);
Basically it deletes any group from phpbb_groups that doesn't have a user ID attached to it, excluding the guest group and admin (shouldn't get deleted by this query anyway but I added the >2 just in case). I've been having issues with my test site after running this query (some functions in functions.php aren't being recognised). These errors started after I ran this query, but surely it can't be the cause of the problems!? Can it?
User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Re: Is this SQL query ok?

Post by drathbun »

Before answering this question, what problem do you think you are trying to solve? :)

If you're having a problem with lots of orphaned groups, you should probably find / fix that rather than apply a bandaid such as this.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image
Post Reply

Return to “[2.0.x] MOD Writers Discussion”