Which item is the highlight for an album?

marcusbrutus

Joined: 2005-11-17
Posts: 64
Posted: Wed, 2005-11-30 06:32

Hi all,
I'm writing a prog to make DVDs from my website(s).
So far I have this:
http://gallery.menalto.com/node/40191
which produces acceptable results.

I've figured out many of the ways that g2 stores data,
however the one thing that escapes me is finding out
which item is the highlight for an album.

Would someone be able to enlighten me?

Thanks,

Marcus.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-30 12:19

get the albumd id. get the thumbnail for the album (GalleryCoreApi::fetchThumb....) that's the album highlight.

 
marcusbrutus

Joined: 2005-11-17
Posts: 64
Posted: Wed, 2005-11-30 15:29

Thanks for your help valiant,
I browsed through the php you mentioned and found this:

            SELECT
              [GalleryDerivative::id], [GalleryChildEntity::parentId]
            FROM
              [GalleryDerivative], [GalleryChildEntity]
            WHERE
              [GalleryDerivative::id] = [GalleryChildEntity::id]
              AND
              [GalleryChildEntity::parentId] IN (' . $idMarkers . ')

and was able to do something like this:

$ mysql -pPASSWORD -uroot gallery2 -e 'SELECT Site_Derivative.Site_Id, Site_ChildEntity.Site_parentId FROM Site_Derivative, Site_ChildEntity WHERE Site_Derivative.Site_id=Site_ChildEntity.Site_id AND Site_ChildEntity.Site_parentId=353'
(where 353 was the itemID of the album I was interested in)

This does, indeed, return the ID of the thumbnail!

+---------+---------------+
| Site_Id | Site_parentId |
+---------+---------------+
|     364 |           353 |
+---------+---------------+

$ mysql -pPASSWORD -uroot gallery2 -e 'SELECT Site_Id, Site_derivativeSourceId FROM Site_Derivative WHERE Site_id=364 '

+---------+-------------------------+
| Site_Id | Site_derivativeSourceId |
+---------+-------------------------+
|     364 |                     362 |
+---------+-------------------------+

$ mysql -pPASSWORD -uroot gallery2 -e 'SELECT Site_Id, Site_derivativeSourceId FROM Site_Derivative WHERE Site_id=362 '

+---------+-------------------------+
| Site_Id | Site_derivativeSourceId |
+---------+-------------------------+
|     362 |                     361 |
+---------+-------------------------+

Which finally gives me the result I want. (The image itself)

Do I really need to loop queries until I find an ID that exists in the Item table?
or is there a neater way?

Thanks again,

Marcus.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-30 15:33

generally, you should always use the G2 API and not db queries.

see:
http://gallery.menalto.com/node/40860

 
marcusbrutus

Joined: 2005-11-17
Posts: 64
Posted: Wed, 2005-11-30 16:40

Thanks valiant,

that makes sense, however, I know nothing of php and I wouldn't know
where to start with using API functions from a bash script.
I'll see what I can find out.

The script I've mentioned above uses the same sql select commands all
the way through. I've now succesfully written a test script that
gives the original image from the thumbnail highlight.
It's all VERY crude I'm afraid, but I barely understand what I'm doing ;)

Marcus