We have done a Sql query against the Gallery database but the record return is 5000+ greater than the number of actual images on the filesystem. We are trying to get a clean export of the database that matches the images on disk. Does anyone know of a Gallery feature or module that can do this?
Thanks
Scott Medaugh
Posts: 16504
Why not do a DB dump?
The query is probably returning the resized versions along with the thumbs. If you go to Site Admin > Maintenance run the System Info task you can post those details and we'll be able to better give you an idea of how many items, albums, users, etc that Gallery thinks there are.
You could also do a directory listing of g2data/albums that would contain all of the original, untouched images in their directory structure.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 8339
So what kind of output are you looking for?
the path of each item?
title:path?
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 5
The resized version is starting to look along what we are thinking as well. A directory listing of the albums shows us about 18000 actual files while the database query returns about 23000 records. We are trying to pull all metadata with all record info for a special year end project report. The maintenance system info (minus proprietary naming info) is below:
Gallery version = 2.3 core 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.1.6 apache2handler
Webserver = Apache/2.2.3 (Red Hat)
Database = mysqli 5.0.45-log, lock.system=database
Toolkits = ImageMagick, Ffmpeg, jpegtran, Exif, Thumbnail, LinkItemToolkit, Getid3, SquareThumb
Acceleration = none/0, none/0
Operating system = Linux xxxxxx.xxxxx.com 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:15 EDT 2008 x86_64
Default theme = matrix
gettext = enabled
Locale = en_US
Browser = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Zune 4.0; Creative ZENcast v2.01.01)
Rows in GalleryAccessMap table = 7882
Rows in GalleryAccessSubscriberMap table = 26898
Rows in GalleryUser table = 305
Rows in GalleryItem table = 26879
Rows in GalleryAlbumItem table = 2359
Rows in GalleryCacheMap table = 0
Posts: 4342
Post your query - it should be a trivial one-line query to get what you want, maybe you've made a simple error?
Posts: 5
We used a php script which is below:
[code]
<?
function fixQuotes($string)
{
$string = str_replace( chr(147), "\"\"", $string);
$string = str_replace( chr(148), "\"\"", $string);
return $string;
}
***Relevant proprietary info removed****
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query=
"SELECT * " .
"FROM g2_Item, g2_FileSystemEntity, g2_User, g2_ChildEntity " .
"WHERE " .
" g2_Item.g_id = g2_FileSystemEntity.g_id AND " .
" g2_Item.g_ownerId = g2_User.g_id AND " .
" g2_Item.g_id = g2_ChildEntity.g_id AND " .
" g2_Item.g_canContainChildren = false " .
"ORDER BY g2_Item.g_id ASC " .
# "LIMIT 10" .
";";
# echo "Query: $query\n";
$result=mysql_query($query);
$num=mysql_numrows($result);
# echo "Rows = $num\n";
echo "ID~~Filename~~Path~~Project~~Title~~Description~~Summary~~Keywords~~Date~~ Owner~~Source~~Country~~State~~City~~Other Location~~County~~Shoot Date~~Credit~ ~Photographer#%#%#%";
$i=0;
while ($i < $num)
{
$id=mysql_result($result,$i,"g2_Item.g_id");
$filename=mysql_result($result,$i,"g2_FileSystemEntity.g_pathComponent") ;
$path="";
$parentid=mysql_result($result,$i,"g2_ChildEntity.g_parentId");
$projectName="";
while($parentid != 7 && $parentid != "")
{
$proj_query=
"SELECT * " .
"FROM g2_Item, g2_FileSystemEntity, g2_ChildEntity " .
"WHERE " .
" g2_Item.g_id = $parentid AND " .
" g2_Item.g_id = g2_FileSystemEntity.g_id AND " .
" g2_ChildEntity.g_id = g2_FileSystemEntity.g_id;" ;
# echo "PROJ query:$proj_query\n";
$proj_result=mysql_query($proj_query);
$path = mysql_result($proj_result,0,"g2_FileSystemEntity.g_pathC omponent") . "/$path";
if ($projectName == "")
{
$projectName=mysql_result($proj_result,0,"g2_Item.g_titl e");
}
$parentid=mysql_result($proj_result,0,"g2_ChildEntity.g_parentId ");
}
# param to use to remove html encoding from fields -- htmlspecialchars_decode($ str);
$title=fixQuotes(mysql_result($result,$i,"g2_Item.g_title"));
# $title=str_replace(","," ",$title);
$description=fixQuotes(mysql_result($result,$i,"g2_Item.g_description")) ;
$description=str_replace(chr(10), " ", $description);
$description=str_replace(chr(13), " ", $description);
$description=str_replace(""", "'", $description);
$description=str_replace("&", "&", $description);
# $description=str_replace(",","~~",$description);
$summary=fixQuotes(mysql_result($result,$i,"g2_Item.g_summary"));
# $summary=str_replace(",", "~~", $summary);
$summary=str_replace(""", "'", $summary);
$summary=str_replace("&", "&", $summary);
$keywords=fixQuotes(mysql_result($result,$i,"g2_Item.g_keywords"));
# $keywords=str_replace(",", "~~", $keywords);
$keywords=str_replace(""", "'", $keywords);
$keywords=str_replace("&", "&", $keywords);
$createDate=mysql_result($result,$i,"g2_Item.g_originationTimestamp");
$convertedDate=date('Y-m-d h:i:s',$createDate);
$owner=mysql_result($result,$i,"g2_User.g_fullName");
echo "$id~~$filename~~$path$filename~~$projectName~~$title~~$description ~~$summary~~$keywords~~$convertedDate~~$owner~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ #%#%#%";
# echo "$id,$convertedDate\n";
$i++;
}
?>
[code]
Posts: 4342
Good lord, seems massively complicated. Why aren't you just searching for all GalleryItems?OK, that's not very helpful. Let me think a bit.
Right - I'm going to stick my neck out and say that your file estimate is wrong, and that the query is (correctly) returning the right items in your database. If you disagree, see if you can find out which items returned by the query are duplicates or otherwise shouldn't be returned.
Resizes are GalleryEntities but not GalleryItems nor GalleryFilesystemEntities so I don't see that they would affect your search.
Posts: 8339
You know I already have scripts capable of recursive display.
Like my mediaRss generator
http://www.flashyourweb.com/gallery2/mediaRss.php?g2_itemId=418&recursive=true
And could easily be customized to list in any format.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2