summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-12-15 13:18:55 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-12-15 13:18:55 +0000
commit1a8de008cd10b695444681c5f0d87514ffbb5e51 (patch)
treea507366e720de15b4c652c598486a51a6a02fe16 /phpfspot.class.php
parent4dc7907678f1709ef347ee2922cce1b4113eedb0 (diff)
issue79, fixed a little bug introduced by arun's patches for showing only certain tags
git-svn-id: file:///var/lib/svn/phpfspot/trunk@313 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php34
1 files changed, 21 insertions, 13 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 11b16fd..a2ef466 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -674,19 +674,23 @@ class PHPFSPOT {
/* return a search result */
if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '') {
$query_str = "
- SELECT DISTINCT photo_id
- FROM photo_tags pt
+ SELECT DISTINCT pt1.photo_id
+ FROM photo_tags pt1
+ INNER JOIN photo_tags pt2
+ ON pt1.photo_id=pt2.photo_id
+ INNER JOIN tags t1
+ ON pt1.tag_id=t1.id
INNER JOIN photos p
- ON p.id=pt.photo_id
- INNER JOIN tags t
- ON pt.tag_id=t.id
- WHERE t.name LIKE '%". $_SESSION['searchfor'] ."%'";
+ ON pt1.photo_id=p.id
+ INNER JOIN tags t2
+ ON pt2.tag_id=t2.id
+ WHERE t1.name LIKE '%". $_SESSION['searchfor'] ."%' ";
if(isset($additional_where_cond))
$query_str.= "AND ". $additional_where_cond ." ";
if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) {
- $query_str.= "AND t.name IN ('".implode("','",$this->cfg->show_tags)."')";
+ $query_str.= "AND t2.name IN ('".implode("','",$this->cfg->show_tags)."')";
}
if(isset($order_str))
@@ -706,15 +710,18 @@ class PHPFSPOT {
$selected.= $tag .",";
$selected = substr($selected, 0, strlen($selected)-1);
+ /* photo has to match at least on of the selected tags */
if($_SESSION['tag_condition'] == 'or') {
$query_str = "
- SELECT DISTINCT pt.photo_id
- FROM photo_tags pt
- INNER JOIN photos p
- ON p.id=pt.photo_id
+ SELECT DISTINCT pt1.photo_id
+ FROM photo_tags pt1
+ INNER JOIN photo_tags pt2
+ ON pt1.photo_id=pt2.photo_id
INNER JOIN tags t
- ON pt.tag_id=t.id
- WHERE pt.tag_id IN (". $selected .")
+ ON pt2.tag_id=t.id
+ INNER JOIN photos p
+ ON pt1.photo_id=p.id
+ WHERE pt1.tag_id IN (". $selected .")
";
if(isset($additional_where_cond))
$query_str.= "AND ". $additional_where_cond ." ";
@@ -726,6 +733,7 @@ class PHPFSPOT {
if(isset($order_str))
$query_str.= $order_str;
}
+ /* photo has to match all selected tags */
elseif($_SESSION['tag_condition'] == 'and') {
if(count($_SESSION['selected_tags']) >= 32) {