view m-toolbox/classes/+utils/@repository/getCollectionIDs.m @ 51:9d5c88356247
database-connection-manager
Make unit tests database connection parameters configurable
author |
Daniele Nicolodi <nicolodi@science.unitn.it> |
date |
Wed, 07 Dec 2011 17:24:37 +0100 (2011-12-07) |
parents |
9174aadb93a5 |
children |
|
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