coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: Prisoner_24601 on September 08, 2006, 06:57:44 PM

Title: Delete Empty Albums?
Post by: Prisoner_24601 on September 08, 2006, 06:57:44 PM
CPG 1.4.9 -- brand new fresh install, too.  Very, spiffy, folks!
MySQL 4.1.7
PHP 5.1.1
Win 2003 Server

I've done a lot of moving and other changes to my Gallery and there are a lot of albums that are now left with zero pictures.  Is there any way of deleting all these albums with zero pictures, other than clicking the "delete" button for each album?  I do have phpMyAdmin ....

Thanks in advance!

==========

Background:

I read Stramm's post (I DO use the Search Engine!  I do!):

Quote from: Stramm on July 01, 2006, 12:40:19 PM
delete the albums and pictures in them and the user galleries category disappears
to delete empty albums
http://forum.coppermine-gallery.net/index.php?topic=31917.msg148529#msg148529

and went to the linked thread, where it says ...

Quote from: Stramm on May 29, 2006, 02:55:44 PM
if the album is empty you won't see it. For that click 'properties' next to any visible (public) album. Now you'll see a dropdown box on the top right side. Look for user galleries here. User galleries can be found looking for () and the users name in it. Like '(Stramm) My Album'. Select the album, then click 'parent category' (left of the dropdown). Magic... you'll now see the empty album and can hit the 'delete' button

... however, as you can see (http://www.saxpics.com/cpg143/index.php?cat=1849&page=2), you can still see the empty albums, even if you're not logged in.  Probably this is because I (Administrator) uploaded these albums.
Title: Re: Delete Empty Albums?
Post by: Nibbler on September 08, 2006, 07:04:36 PM
This should do it. Backup first.

DELETE FROM a USING cpg_albums AS a LEFT JOIN cpg_pictures AS p ON p.aid = a.aid WHERE p.pid IS NULL

Not a plugin contribution, moving.
Title: Re: Delete Empty Albums?
Post by: Prisoner_24601 on September 08, 2006, 07:11:05 PM
Thanks for moving.  Sorry.  Too many browser windows open.
Title: Re: Delete Empty Albums?
Post by: Nibbler on September 08, 2006, 07:19:43 PM
Just to note:If you use the 'linked files' feature then don't use the above.
Title: Re: Delete Empty Albums?
Post by: Prisoner_24601 on September 08, 2006, 07:20:35 PM
I think that worked!  Deleted 194 entries, which "sounds" about right.  Thanks very much: saved a lot of time!

Another note to anyone else that tries this: where Nibbler has "cpg_", make sure you substitute the correct prefix for your tables!  Mine's "cpg143_".