+ /* individual tags are seperated by ',' */
+
+ /* use and AND query between tags as a default
+ a good explanation on different ways of doing this can be found at:
+ http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html
+ */
+
+ if (isset($_REQUEST["C"]))
+ {
+ $result = $DB->query("SELECT count(*) as total from (SELECT p.id FROM photo_tags pt, photos p, tags t".
+ " WHERE pt.tag_id = t.id".
+ " AND (t.name COLLATE NOCASE IN ($tags))".
+ " AND p.id = pt.photo_id ".
+ " GROUP BY p.id HAVING COUNT( p.id )=$nrtags)");
+ }
+ else
+ {
+ $result = $DB->query("SELECT base_uri, filename, p.id as id FROM photo_tags pt, photos p, tags t".
+ " WHERE pt.tag_id = t.id".
+ " AND (t.name COLLATE NOCASE IN ($tags))".
+ " AND p.id = pt.photo_id ".
+ " GROUP BY p.id HAVING COUNT( p.id )=$nrtags".
+ " LIMIT $OFFSET, $N");
+
+ }