This is probably just a typical php mysql fetching question, but I have no experience using it so I figured I'd ask here and find out quicker.
The containing mysql table is 'g2_descendentcountsmap' inside the database 'gallery' and the rows are:
g_userId g_itemId g_descendentCount
5 7 4001
6 7 4001
...
...where the I want to fetch the 4001 field ('g_descendentCount' column) from either of these two rows.
If possible, I would like to retrieve the number inside a variable (like $totalitems or similar) for subsequent use in math operations.
Thanks in advance,
Phil
Posts: 32509
see:
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methodfetchDescendentCounts
Posts: 29
Thanks but I actually found out myself shortly after posting...
Thanks anyways,
Phil
Posts: 32509
If anyone later finds this topic:
- don't hardcode numbers like 5 (guest) or 7 (root album). use GalleryCoreApi::getDefaultAlbumId() and ::getAnonymousUserId().
- don't use proprietary mysql_ code since it's not portable to other DBs, use g2's $storage methods instead
- don't write SQL queries for things that are covered by the core API since the API is supported and versioned while your SQL code might just stop to work after an upgrade because things have been refactored in gallery.
Posts: 29
Hey valiant, I'm trying to get things right so I want to do this the 'correct' way. I have no clue how to do what you are saying... I want to execute the query from drupal (in the content of a page) through the gallery GalleryCoreApi... but I guess I'd have to php include a gallery core file so that the function can get called (or maybe not, since I am using the drupal gallery module???). What code would I need to do what you are saying?
Thx
Posts: 32509
the drupal integration for gallery already includes the gallery files and has the necessary functions to init gallery.
i'd look into the g2 integration for drupal and extending it for your needs.
--------------
Enter the Gallery 2 Theme Contest today!