[pLog-svn] r4747 - plog/trunk/class/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sat Feb 17 17:38:58 EST 2007


Author: oscar
Date: 2007-02-17 17:38:58 -0500 (Sat, 17 Feb 2007)
New Revision: 4747

Modified:
   plog/trunk/class/dao/locations.class.php
Log:
Added methods for finding all the locations associated to resources and to articles.

Modified: plog/trunk/class/dao/locations.class.php
===================================================================
--- plog/trunk/class/dao/locations.class.php	2007-02-17 22:08:40 UTC (rev 4746)
+++ plog/trunk/class/dao/locations.class.php	2007-02-17 22:38:58 UTC (rev 4747)
@@ -155,6 +155,59 @@
 		}
 		
 		/**
+		 * Retrieve all the locations that are associated to resources
+		 *
+		 * @param blogId
+		 * @param albumId
+		 * @return An array of Location objects
+		 */
+		function getResourceLocations( $blogId, $albumId = -1 )
+		{			
+			$query = "SELECT DISTINCT l.* FROM ".$this->getPrefix()."locations AS l, ".$this->getPrefix()."gallery_resources AS gr
+			          WHERE l.id = gr.loc_id AND l.blog_id = '".Db::qstr( $blogId )."' AND gr.owner_id = '".Db::qstr( $blogId )."'";
+			if( $albumId != -1 )
+				$query .= " AND gr.album_id = '".Db::qstr( $albumId )."'";
+				
+			print($query);
+			
+			$result = $this->Execute( $query );
+			if( !$result )
+				return( Array());
+				
+			$locations = Array();
+			while( $row = $result->FetchRow()) {
+				$locations[] = $this->mapRow( $row );
+			}
+			
+			return( $locations );
+		}
+		
+		/**
+		 * Retrieve all the locations that are associated to articles
+		 *
+		 * @param blogId
+		 * @return An array of Location objects
+		 */
+		function getArticleLocations( $blogId )
+		{			
+			$query = "SELECT DISTINCT l.* FROM ".$this->getPrefix()."locations AS l, ".$this->getPrefix()."articles AS a
+			          WHERE l.id = a.loc_id AND l.blog_id = '".Db::qstr( $blogId )."' AND a.blog_id = '".Db::qstr( $blogId )."'";
+				
+			print($query);
+			
+			$result = $this->Execute( $query );
+			if( !$result )
+				return( Array());
+				
+			$locations = Array();
+			while( $row = $result->FetchRow()) {
+				$locations[] = $this->mapRow( $row );
+			}
+			
+			return( $locations );
+		}		
+		
+		/**
 		 * update the given location
 		 */
 		function updateLocation( $loc )



More information about the pLog-svn mailing list