Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 08:05:27 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
149679 Posts in 21101 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: delete many news at ones  (Read 392 times)
babsy

Offline Offline

Posts: 311


« on: February 04, 2010, 04:51:42 PM »

HI

i have a client, who has been filling his page with news for the last 3 years, and now the page is getting slow, so i told him to start deleting old news? But it there a fast way of deleting old news (the news are on multiple pages, diff. news)?? anyone knows a fast way!

idea for next WB Smiley make the possibility to delete multible news and multible news post at the same time, maybe it would be good to just select the ones you want to delete and then pres (delete) instead of having to put one by one in the (trash) Smiley

Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1680



« Reply #1 on: February 04, 2010, 05:54:56 PM »

you can connect to DB using phpmyadmin and manualy delete all entries from news table..
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
doc
Guest
« Reply #2 on: February 04, 2010, 06:23:08 PM »

Hi,

one comment in addition to the post from crnogorac081.

You could use SQL statements from phpMyAdmin to select (or delete) all news entries older than a certain date.

Simply use something like below in phpMyAdmin to select all news entries older than yyyyyy:
SELECT * FROM `xxx_mod_news_posts` WHERE `posted_when` < 'yyyyyyyyy'

Just replace xxx_ with the prefix of your database if any and yyyyyyy with the timestamp of the first post you want keep. Use PHP date function or this online service to convert Unix timestamp into human readable format. Of course you could also write two lines of code (e.g. in a code section to get the work done).

Doc
Logged
babsy

Offline Offline

Posts: 311


« Reply #3 on: February 04, 2010, 08:41:04 PM »

thank you Smiley i will try that tomorrow!
Logged
babsy

Offline Offline

Posts: 311


« Reply #4 on: February 05, 2010, 03:11:02 PM »

This works fine.. i can delete without a problem Smiley (just have to delete the actual php page also.. through FTP Smiley
Logged
DarkViper
Development Team
*****
Offline Offline

Posts: 1052


« Reply #5 on: February 05, 2010, 04:29:25 PM »

it works as long you have no comments saved for your news.. Then you must delete the corresponding comments also.
You can do it if you execute following 2 SQL-Queries after each other.:

Code:
replace xxxx with your TABLE_PREFIX
>>first execute
DELETE `t1`, `t2` FROM `xxxx_mod_news_posts` AS `t1`
INNER JOIN `xxxx_mod_news_comments` AS `t2`
WHERE `t1`.`post_id` = `t2`.`post_id` AND `t1`.`posted_when` < UNIX_TIMESTAMP( '2005-03-27 03:00:00' )

>>second execute
DELETE FROM `xxxx_mod_news_posts`
WHERE `posted_when` < UNIX_TIMESTAMP( '2005-03-27 03:00:00' )

First query will delete all posts with all attached comments
Second query will delete all other posts without comments.
The order of executing queries is very important!

The SQL-function UNIX_TIMESTAMP makes it easy to insert the timestamp. The format is:  ( 'yyyy-mm-dd hh:mm:ss' )

Logged

Anleitungen lesen und selber nachdenken ist anstrengend...  Da lass ich doch lieber andere für mich denken...

In 1984:  Nineteen Eighty-Four is a unrealistic utopia!!
In 2012:  Nineteen Eighty-Four is a little piece only of our reality!!
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!