User Tools

Site Tools


podoc:count_subalbums_by_album_sql_function

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
podoc:count_subalbums_by_album_sql_function [2007/04/18 13:45] Luudpodoc:count_subalbums_by_album_sql_function [2007/10/19 20:29] (current) Luud
Line 8: Line 8:
  
 Count the number of sub-albums in a particular album. Count the number of sub-albums in a particular album.
- 
-There are two versions, one that counts all albums and one that counts only those albums up to a given access rights setting. 
  
 === Purpose === === Purpose ===
Line 17: Line 15:
 === Schema === === Schema ===
  
-<code+<code sql> 
-create function count_subalbums_by_album(integer) returns bigint +create function count_subalbums_by_album(integer, integer, varchar[]) returns bigint as ' 
-as 'select count(identifier) from album where parent_album = $1' language 'sql'; +select count(identifier) from album where parent_album = $1 and can_access_album(identifier, $2, $3); 
-</code> +' language 'sql';
- +
-<code+
-create function count_subalbums_by_album(integer, integer) returns bigint +
-as 'select count(identifier) from album where parent_album = $1 and access_rights <= $2' language 'sql';+
 </code> </code>
  
Line 45: Line 39:
 = Version 2.29 = = Version 2.29 =
  
-<code>+<code sql>
 create function count_subalbums_by_album(integer) returns bigint create function count_subalbums_by_album(integer) returns bigint
 as 'select count(identifier) from album where parent_album = $1' language 'sql'; as 'select count(identifier) from album where parent_album = $1' language 'sql';
 </code> </code>
  
-<code>+<code sql>
 create function count_subalbums_by_album(integer, integer) returns bigint create function count_subalbums_by_album(integer, integer) returns bigint
 as 'select count(identifier) from album where parent_album = $1 and access_rights <= $2' language 'sql'; as 'select count(identifier) from album where parent_album = $1 and access_rights <= $2' language 'sql';
 +</code>
 +
 += Version 2.34 =
 +
 +<code sql>
 +drop function count_subalbums_by_album(integer);
 +drop function count_subalbums_by_album(integer, integer);
 +
 +create or replace function count_subalbums_by_album(integer, integer, varchar[]) returns bigint as '
 +select count(identifier) from album where parent_album = $1 and can_access_album(identifier, $2, $3);
 +' language 'sql';
 </code> </code>
  
podoc/count_subalbums_by_album_sql_function.1176903906.txt.gz · Last modified: 2007/04/18 13:45 by Luud