[pLog-svn] r4185 - plog/branches/lifetype-1.1.2/class/gallery/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Oct 25 07:34:36 GMT 2006


Author: oscar
Date: 2006-10-25 07:34:35 +0000 (Wed, 25 Oct 2006)
New Revision: 4185

Modified:
   plog/branches/lifetype-1.1.2/class/gallery/dao/galleryresources.class.php
Log:
possible fix for issue 1099 (http://bugs.lifetype.net/view.php?id=1099) -- gallery resources using way too much memory


Modified: plog/branches/lifetype-1.1.2/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/branches/lifetype-1.1.2/class/gallery/dao/galleryresources.class.php	2006-10-24 22:02:31 UTC (rev 4184)
+++ plog/branches/lifetype-1.1.2/class/gallery/dao/galleryresources.class.php	2006-10-25 07:34:35 UTC (rev 4185)
@@ -189,28 +189,25 @@
                                    $page = DEFAULT_PAGING_ENABLED, 
                                    $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
         {
-        	$resources = $this->getMany( "owner_id", 
-        								 $ownerId, 
-        	                             CACHE_RESOURCES_USER,
-										 null,
-										 Array( "date" => "ASC" ),
-										 $searchTerms );
-            if( !$resources )
-            	return Array();
-            	
-           	$result = Array();
-           	foreach( $resources as $resource ) {
-				if( $this->check( $resource, $ownerId, $albumId, $resourceType )) {
-					$result[] = $resource;
-				}
-           	}
-			
-			// check if we need to do any paging
-			if( $page > DEFAULT_PAGING_ENABLED )
-				$result = array_slice( $result,	($page-1) * $itemsPerPage, $itemsPerPage );
-				
+		$resources = Array();
+		$query = "SELECT id FROM ".$this->getPrefix()."gallery_resources WHERE owner_id = '".Db::qstr($ownerId)."'";
+		if( $albumId != GALLERY_NO_ALBUM )
+			$query .= " AND album_id = '".Db::qstr($albumId)."'";
+		if( $resourceType != GALLERY_RESOURCE_ANY )
+			$query .= " AND resource_type = '".Db::qstr($resourceType)."'";
+		if( $searchTerms != "" )
+			$query .= " AND (".$this->getSearchConditions( $searchTerms ).")";
 
-            return $result;
+		$result = $this->Execute( $query, $page, $itemsPerPage );
+		if( !$result )
+			return $resources;
+
+		while( $row = $result->FetchRow()) {
+			// use the primary key to retrieve the items via the cache
+			$resources[] = $resource = $this->get( "id", $row["id"], CACHE_RESOURCES );
+		}
+
+            return $resources;
         }
         
         /**



More information about the pLog-svn mailing list