select c.collection_id, c.title
from pa_collections c, pa_collection_photo_map m
where m.photo_id = :photo_id
and m.collection_id = c.collection_id
and owner_id = :user_id
order by c.title
select name from cr_items where item_id = :photo_id
select count(*)
from cr_items
where name = :filename
and parent_id = :new_album_id
select parent_id from cr_items where item_id = :photo_id
select rel_id from cr_child_rels
where parent_id = :old_album_id
and child_id = :photo_id
update cr_items
set parent_id = :new_album_id
where item_id = :photo_id
update cr_child_rels
set parent_id = :new_album_id
where parent_id = :old_album_id
and child_id = :photo_id
update acs_objects
set context_id = :new_album_id
where object_id = :photo_id or object_id = :rel_id
select ci.item_id as thumb_photo_id,
i.image_id as thumb_image_id,
i.height as thumb_height,
i.width as thumb_width
from cr_items ci,
cr_items ci2,
cr_child_rels ccr2,
images i
where ccr2.relation_tag = 'thumb'
and ci.item_id = ccr2.parent_id
and ccr2.child_id = ci2.item_id
and ci2.live_revision = i.image_id
and ci.live_revision is not null
and ci.item_id = :photo_id