added support for batch retrieval of tag IDs

this will be necessary for upcoming changes
fixed use of quotes

sigh
fixed handling of tag combinations

in order for faceted search to work, tags should be combined with AND -
previously, OR was being used erroneously (though there were errors in
that logic as well)

thanks to tillsc, @bengillies and @cdent for providing the SQL fu