Album-Thumbnail relationship in the Database

dryicerx

Joined: 2008-07-22
Posts: 1
Posted: Tue, 2008-07-22 15:39

Hello,

I am trying to integrate my gallery2 installation with my website (so I can access the album content directly from the Gallery2 database instead of going through plugins/modules). I am having a hard time finding where the relationship between the Album and corresponding Thumbnail images are in the SQL Database.

For example
Link to Album is: /gallery/main.php?g2_itemId=4180
Thumbnail for Album: gallery/main.php?g2_view=core.DownloadItem&g2_itemId=4184&g2_serialNumber=4

What I need is to be able to get thumbnail's g2_itemId for a given album's g2_itemId (and g2_serialNumber if that makes a difference).

Really appreciate your help, wondering around phpmyadmin for hours turned up nothing on this. Thanks!

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-07-22 19:48

Best way is to run G2 in embedded mode, then you can use the API, specifically GalleryCoreApi::FetchThumbnailsByItemIds(array($myAlbumId));
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methodfetchThumbnailsByItemIds

Otherwise...

SELECT g2_ChildEntity.g_id
FROM g2_ChildEntity, g2_Derivative
WHERE g2_ChildEntity.g_parentId = <myAlbumId>
AND g2_ChildEntity.g_id = g2_Derivative.g_id
AND g2_Derivative.g_derivativeType = 1;