User Tools

Site Tools


podoc:count_photos_by_album_sql_function

Database Function Description of "count_photos_by_album"

Name

count_photos_by_album

Description

Count the photos per album for all albums.

Purpose

To retrieve the number of photos per album for all albums.

Schema

CREATE 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';

History

Used first

Version 2.5

Used last

Still in use

Change history

= Version 2.5 =

CREATE FUNCTION count_photos_by_album(INTEGER) RETURNS BIGINT
AS 'select count(photo.identifier)
     from album_content, photo
    where album_content.photo=photo.identifier
      and album = $1' LANGUAGE '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';

= Version 2.34 =

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';
podoc/count_photos_by_album_sql_function.txt · Last modified: 2007/10/19 16:29 by Luud