Browse Source

Bug fix: Lors de la recherche d'element, on exluait les tags ne correspondant pas au filtre.

bastien 13 years ago
parent
commit
13e5ecfe08
1 changed files with 27 additions and 8 deletions
  1. 27 8
      src/Muzich/CoreBundle/Repository/ElementRepository.php

+ 27 - 8
src/Muzich/CoreBundle/Repository/ElementRepository.php View File

34
   {;
34
   {;
35
     $params = array();
35
     $params = array();
36
     $join_personal = '';
36
     $join_personal = '';
37
+    //$query_with = '';
38
+    $where = '';
37
     
39
     
38
     switch ($searcher->getNetwork())
40
     switch ($searcher->getNetwork())
39
     {
41
     {
49
       break;
51
       break;
50
     }
52
     }
51
     
53
     
52
-    $query_with = "WITH ";
54
+//    $query_with = "WITH ";
55
+//    foreach ($searcher->getTags() as $tag_id)
56
+//    {
57
+//      if ($query_with != "WITH ")
58
+//      {
59
+//        $query_with .= "OR ";
60
+//      }
61
+//      $query_with .= "t.id = :tagid".$tag_id." ";
62
+//      $params['tagid'.$tag_id] = $tag_id;
63
+//    }
64
+    
53
     foreach ($searcher->getTags() as $tag_id)
65
     foreach ($searcher->getTags() as $tag_id)
54
     {
66
     {
55
-      if ($query_with != "WITH ")
67
+      if ($where == '')
68
+      {
69
+        $where .= 'WHERE t.id = :tid'.$tag_id;
70
+      }
71
+      else
56
       {
72
       {
57
-        $query_with .= "OR ";
73
+        $where .= ' OR t.id = :tid'.$tag_id;
58
       }
74
       }
59
-      $query_with .= "t.id = :tagid".$tag_id." ";
60
-      $params['tagid'.$tag_id] = $tag_id;
75
+      $params['tid'.$tag_id] = $tag_id;
61
     }
76
     }
62
         
77
         
63
-    $query_string = "SELECT e, et, t, eu, g
78
+    $query_string = "SELECT e, et, t2, eu, g
64
       FROM MuzichCoreBundle:Element e 
79
       FROM MuzichCoreBundle:Element e 
65
-      LEFT JOIN e.group g JOIN e.type et JOIN e.tags t $query_with 
66
-        JOIN e.owner eu $join_personal
80
+      LEFT JOIN e.group g 
81
+      JOIN e.type et 
82
+      LEFT JOIN e.tags t 
83
+      LEFT JOIN e.tags t2 
84
+      JOIN e.owner eu $join_personal
85
+      $where
67
       ORDER BY e.created DESC "
86
       ORDER BY e.created DESC "
68
     ;
87
     ;
69
     
88