view m-toolbox/classes/+utils/@repository/getCollectionIDs.m @ 11:9174aadb93a5 database-connection-manager

Add LTPDA Repository utility functions into utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents
children
line wrap: on
line source

function ids = getCollectionIDs(conn, cid)
% GETCOLLECTIONIDS  Return the IDs of the object composing a collection.
%
% CALL:
%
%   ids = utils.repository.getCollectionIDs(conn, cid)
%
% PARAMETERS:
%
%   CONN   database connection implementing java.sql.Connection
%   CID    collection id
%

  rows = utils.mysql.execute(conn, 'SELECT nobjs, obj_ids FROM collections WHERE id = ?', cid);
  if isempty(rows)
    error('### collection %d not found', cid);
  end
  nobjs = rows{1};
  ids = strread(rows{2}, '%d', 'delimiter', ',');
  if length(ids) ~= nobjs
    error('### inconsistent collection description');
  end
  % transform column vector in row vector
  ids = ids';
  
end