Data Model?

DavidF

Joined: 2006-02-27
Posts: 11
Posted: Mon, 2006-02-27 19:18

Sorry for the double post, I had this up on the general discussion forum and then realized that this is probably a better place to ask this question.

I would like to write a select query against the MySQL database for my Gallery2 instance. Is the db structure documented anywhere?

Essentially, I want to query out all image records (title, caption, albumname) where a custom field named 'custom2' is not null. The custom field is a 'common field'.

Any help would be appreciated.

Thanks,

David.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2006-02-27 20:36

there are some quite old diagrams here:
http://gallery.menalto.com/gallery/miscellaneous/

entity tables match the class structure, so if you look at modules/core/classes/GalleryItem.class and see what it extends then you'll find all the related tables. Each of these tables are linked by a common g_id value.

 
DavidF

Joined: 2006-02-27
Posts: 11
Posted: Tue, 2006-02-28 15:26

Thanks,

That has gotten me started. I can't seem to find a key between CustomFieldMap and Item tables. CustomFieldMap uses g_itemid as a primary key, Item uses g_id.

I can grab the custom field names and values that I want, now I just want to join that data with the photo and album attribute data for each related record.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-02-28 19:18

g_id links to g_itemId.
actual entity tables use g_id (ie, GalleryItem extends Gallery..... each will use g_id)

other tables with related data, but not actually part of the same entity, usually use g_itemId.

 
DavidF

Joined: 2006-02-27
Posts: 11
Posted: Tue, 2006-02-28 19:32

Thank you for your response!