Selecting files that match more than one set

Permalink
Hello,

I'm trying to select files from the file manager that are in two or more sets. For a file in a single set I do:

$fileSet = FileSet::getByID(1);
$fileList->filterBySet($fileSet);

I would like to select files that are in both sets 1 and 6 so I was hoping:

$fileSet = FileSet::getByID(array(1,6));
$fileList->filterBySet($fileSet);

would work, but after looking at the API, it won't handle this properly. I've looked in the forums and docs and can't find a solution for this.

Any ideas?

Thanks everyone

haptiK
 
haptiK replied on at Permalink Best Answer Reply
haptiK
As a workaround to my own problem stated above I have been using the following SQL to get the desired result:

SELECT fID
FROM filesetfiles
WHERE fsID IN ('.$this->group.', 9)
GROUP BY fID
HAVING COUNT(DISTINCT fsID) = 2

i then run the results through a for each pulling out the id's to instantiate a File object: File::getByID();

This will have to do for the time being until there is a way to pull out files attached to multiple sets with FileSet::

Kind regards,
haptiK replied on at Permalink Reply
haptiK
where $this->group is just an int value for a set so this would be IN(1,9)