User Tools

Site Tools


podoc:count_photos_by_album_sql_function

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
podoc:count_photos_by_album_sql_function [2007/04/23 10:27]
Luud
podoc:count_photos_by_album_sql_function [2007/10/19 16:29] (current)
Luud
Line 8: Line 8:
  
 Count the photos per album for all albums. Count the photos per album for all albums.
- 
-There are two versions, one that counts all photos and one that counts only those photos up to a given access rights setting. 
  
 === Purpose === === Purpose ===
Line 18: Line 16:
  
 <code sql> <code sql>
-create function count_photos_by_album(integer) returns bigint +create function count_photos_by_album(integer,​ integer, ​varchar[]) returns bigint as ' 
-as '​select count(photo.identifier) +select count(photo) from album_content where album = $1 and can_access_photo(photo$2, $3); 
-     from album_contentphoto +' language '​sql';​
-    where album_content.photo=photo.identifier +
-      and album = $1' language '​sql';​ +
-</​code>​ +
- +
-<code sql> +
-create function count_photos_by_album(integer, ​integer) returns bigint +
-as '​select count(photo.identifier) +
-      ​from album_content, photo, album +
-     where album_content.photo=photo.identifier +
-       and album_content.album=album.identifier +
-       and album_content.album = $1 +
-       and photo.access_rights <= $2' language '​sql';​+
 </​code>​ </​code>​
  
Line 73: Line 59:
 </​code>​ </​code>​
  
 += Version 2.34 =
 +
 +<code sql>
 +drop function count_photos_by_album(integer);​
 +drop function count_photos_by_album(integer,​ integer);
 +
 +create or replace function count_photos_by_album(integer,​ integer, varchar[]) returns bigint as '
 +select count(photo) from album_content where album = $1 and can_access_photo(photo,​ $2, $3);
 +' language '​sql';​
 +</​code>​
podoc/count_photos_by_album_sql_function.txt · Last modified: 2007/10/19 16:29 by Luud