View Single Post
  #5 (permalink)  
Old 04-09-2007, 05:59 PM
acidride acidride is offline
Casual Pligger
 
Join Date: Mar 2007
Posts: 64
//deletes a story and dependencies
function delete_link($link_id)
{
global $db;
$tables = array
(
"pligg_links" => "link_id",
"pligg_comments" => "comment_link_id",
"pligg_feed_link" => "feed_link_id",
"pligg_tags" => "tag_link_id",
"pligg_trackbacks" => "trackback_link_id",
"pligg_votes" => "vote_link_id",
);

foreach($tables as $table => $field)
$db->query("DELETE FROM ".$table." WHERE ".$field." = '".$link_id."'");

return true;
}



You could just do a query for link_id for a certain date range, then then run the delete_link to get rid of the story. It's simple to do. Could even have a script on a cron job that deletes all stories older than say 1 month.

Or you can count how many link_id there are, and if you get over that threshold, then start deleting the oldest link_id until you are back under the threshold.
Reply With Quote