Previous Thread
Next Thread
Print Thread
Rate Thread
#235361 02/06/2003 1:00 AM
Joined: Jul 2001
Posts: 442
Enthusiast
Enthusiast
Offline
Joined: Jul 2001
Posts: 442
I want to delete every post/thread from my test forum, how can I do that all at once with one command?

Sponsored Links
bisbell #235362 02/06/2003 4:50 AM
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Not sure if it can be done with one command.

You will have to know the Keyword of the board you wish to "flush". If you don't know it, then use the:

SELECT Bo_Title, Bo_Keyword
FROM w3t_Boards

That will give you the list of all your boards and you can write down the keyword of the board you wish to flush. If we assume that the keyword is "TestBoard" then to empty all the posts you can use

DELETE
FROM w3t_Posts
WHERE B_Board = "TestBoard"

Finally to reset the counters for your board you need to issue the:

UPDATE w3t_Boards
SET Bo_Total = 0, Bo_Last = 0, Bo_Threads = 0, Bo_LastNumber = 0, Bo_lastMain = 0
WHERE Bo_Keyword = "TestBoard"

I hope this helps.


Nikos
Hal_dup2 #235363 02/06/2003 12:31 PM
Joined: Jul 2001
Posts: 442
Enthusiast
Enthusiast
Offline
Joined: Jul 2001
Posts: 442
Sweet, worked perfect!

bisbell #235364 02/06/2003 12:34 PM
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Nice to hear that.


Nikos
Joined: Jul 2001
Posts: 442
Enthusiast
Enthusiast
Offline
Joined: Jul 2001
Posts: 442
OK, here's another one, how about if I wanted to delete all post/threads in a certain forum that were older than 30 days?

Sponsored Links
bisbell #235366 02/06/2003 2:33 PM
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
It is the same query with an additional where clause.

WHERE B_Board = "TestBoard" AND Bo_Posted < UNIX_TIMESTAMP("2003-01-01 00:00:00")

The above will delete all posts from the TestBoard prior to the 1/1/03 at 00:00:00


Nikos
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
Careful. What about posts with replies?

Joined: Jul 2001
Posts: 442
Enthusiast
Enthusiast
Offline
Joined: Jul 2001
Posts: 442
Woops, I got this when trying it on my "partsforsale" forum:

Here are the results of your command: "WHERE B_Board = "partsforsale" AND Bo_Posted < UNIX_TIMESTAMP("2003-01-01 00:00:00")".
SQL ERROR: Unable to do_query: WHERE B_Board = "partsforsale" AND Bo_Posted < UNIX_TIMESTAMP("2003-01-01 00:00:00")
You have an error in your SQL syntax near 'WHERE B_Board = "partsforsale" AND Bo_Posted < UNIX_TIMESTAMP("2003-01-01 00:00:' at line 1 row(s) affected by your query.

bisbell #235369 02/06/2003 3:31 PM
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Dave is right. I forgot the posts with replies. In effect you can delete posts that have been posted before the time you have specified but are "alive" since someone is posting to them. If we run this query here, then the IIP thread (and a lot more) would be rendered useless.

Luckily you only pasted the WHERE clause and not the DELETE.

Let me think a bit about this


Nikos
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
I thought about this a bit more. There is no easy way to get what you want (for the posts before a certain date). The reason being is (like Dave said) that you endanger yourself of breaking the threads by deleting a post that might have been replied to.

You need to write some sort of script that will retrieve every post before the certain date and then subselect to see if there are any replies to it, then check the date of those replies and delete appropriately.

Sorry but this cannot be done with a simple DELETE statement.


Nikos
Sponsored Links
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
Maybe coloradok5 didn't express clearly what he really wanted to do. The built-in thread expire feature may do what he wants.

joeuser #235372 02/06/2003 11:51 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Yeah, and if you don't want to fool with the whole cron thing.. you can set the forum to expire after x days.... and run doexpire.php from your browser every once in a while.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)