Jump to content
MakeWebGames

cleanup sql help needed with comment table


Recommended Posts

my comment table is getting very large and I am looking for a way to delete some of the old entries without messing with player pages.

the table structure is `cm_id``cm_from``cm_to``cm_comment``cm_days``cm_time`

what i want to do is delete all older comments where there are more than a count of 30 in cm_to. This is way beyond my SQL knowledge, any help is appreciated

Link to comment
Share on other sites

can you not add some thing like

/////////// UNTESTED \\\\\\\\\\\\\\
$mail=mysql_query("SELECT `cm_id` FROM `comments` ORDER BY `cm_time` ASC)");
if (mysql_num_rows($mail)>30) {
$m=mysql_fetch_array(mysql_query("SELECT `cm_id` FROM `comments` ORDER BY `cm_time` ASC LIMIT 0, 1"));
mysql_query("DELETE FROM `comments` WHERE `cm_id` =".$m['cm_id']);
}

btw zeds will delete all posts were the comment is to any one with a higher id then 30 (by the looms of it)

Link to comment
Share on other sites

can you not add some thing like

 

/////////// UNTESTED \\\\\\\\\\\\\\
$mail=mysql_query("SELECT `cm_id` FROM `comments` ORDER BY `cm_time` ASC)");
if (mysql_num_rows($mail)>30) {
$m=mysql_fetch_array(mysql_query("SELECT `cm_id` FROM `comments` ORDER BY `cm_time` ASC LIMIT 0, 1"));
mysql_query("DELETE FROM `comments` WHERE `cm_id` =".$m['cm_id']);
}

 

btw zeds will delete all posts were the comment is to any one with a higher id then 30 (by the looms of it)

I think this is probably what i need. I am not very good with anything but basic scripts. I will go put this into my test area and see what happens......Thanks so much for your assistance!

Zed thanks for the effort but that will delete all comments wherever it was sent to userid over 30......basically all the comments in the game.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...