Recent Topics

1 Jan 16, 2011 12:58    

My b2evolution Version: 4.0.3

Many rarely needed features (such as Spam deleting, mass adding keywords etc.) could be provided editing the database on the server I think,
the free software Heidi SQL is a great tool to do so, e,g:

The mass create function is great but
I have made a mistake using the "mass create" function to import a huge text file.
Now I have >2000 Posts that I would like to delete.
I could do so in PHPmyadmin by filtering them in SQL and say:

dele *  FROM `evo_items__item` WHERE `post_main_cat_ID` = 73

right?

but will B2evo crash or have an broken index after that brutal manipulation?

or maybe I should only set these posts invisible somehow?

any help would be very welcome! Maria from Spain!

2 Jan 16, 2011 18:43

You'd need to delete the entries in evo_post_cats as well ( or whatever it's called ... been ages since I bothered with evo core )

If it was me, I'd probably use evo to delete them so that it removed everything.

$foo = 123; // change to your first post id
$bar = 1234; // number of posts to delete

$crap_cache = get_cache('ItemCache'); // obscure reference, 100 rep points to anyone that gets it ;)
++$bar;

while( $bar )
{
  --$bar;
  $crap = $crap_cache->get_by_ID( $foo + $bar );
  $crap->dbdelete();
}
echo 'Crap removed';

Free typed, but you get the idea.

¥

3 Jan 16, 2011 22:56

cool post, :) but I couldn't get it

does your knowledge of Evo core say that Evo will crash
if I only delete the post in
evo_items
using Heidi-SQL

kisses (K)(K)(K) :p

Maria 8|

4 Jan 16, 2011 23:57

does your knowledge of Evo core say that Evo will crash
if I only delete the post in
evo_items
using Heidi-SQL

This may break your blog. Use the above code instead. Add it to admin.php:63 then open any admin page to run the code.

// Check global permission:
if( ! $current_User->check_perm( 'admin', 'any' ) )
{	// No permission to access admin...
	require $adminskins_path.'_access_denied.main.php';
}

$foo = 123; // change to your first post id
$bar = 1234; // number of posts to delete

$crap_cache = & get_ItemCache();

++$bar;

while( $bar )
{
  --$bar;
  $crap = $crap_cache->get_by_ID( $foo + $bar );
  $crap->dbdelete();
}
echo 'Crap removed'; 

5 Jan 17, 2011 02:48

Thanx a lot, but do I understand corect that

$foo = 123; // I need to put the first _item's number that I want to delete
$bar = 1234;// I need to put the number of items I want to delete...

so in this case it would delete all evo_item form id 123 to (123+1234)=1357
any time I run the edited admin.php ???

So I have to remove it again, right?

But what do I do if the items to delete are not in a continuous number but have a category in common or I want to delete all posts with the status "Deprecated "??

Wouldn't it be clever to use "Visibility / Sharing" "Deprecated " as a delete marker and e.g the HeidiSQL Editor to setting all items to be removed as "Deprecated " by batch ?
and if this hack would instead of deleting from id xxx to Id yyy delete all "Deprecated "?

6 Jan 17, 2011 03:05

Why do you want to keep 2000 posts slowing down your database when you can spend 3 minutes to delete them all?

If you want to delete all posts in a category that's easy as well. You should remove the script when you finish.

$main_category_ID = 123; // change to your category id

if( $rows = $DB->get_col('SELECT post_ID FROM T_items__item WHERE post_main_cat_ID = '.$main_category_ID) )
{
	$crap_cache = & get_ItemCache();
	$count = 0;
	
	foreach( $rows as $post_ID )
	{
		$crap = $crap_cache->get_by_ID( $post_ID );
		if( $crap->dbdelete() )
		{
			$count++;
		}
	}
	$Messages->add("Deleted $count posts", 'success');
}
else
{
	$Messages->add('Selected category is empty', 'error');
}

7 Jan 17, 2011 03:08

Edit the query as you like. To delete all 'deprecated' use this.

SELECT post_ID FROM T_items__item WHERE post_status = "deprecated"

8 Jan 17, 2011 03:15

eres un sol! besito!

I will try that and insert it at line 63 in admin.php!


Form is loading...