Browse Source

Evolution #166: La recherche

bastien 12 years ago
parent
commit
2475997e55

+ 3 - 34
src/Muzich/CoreBundle/Repository/ElementRepository.php View File

83
       ));
83
       ));
84
       
84
       
85
       // On récupère les ids des elements correspondants
85
       // On récupère les ids des elements correspondants
86
-      //$where_string = "WHERE 1 = 2";
87
-      //$params_string = array();
88
       $word_min_length = 0;
86
       $word_min_length = 0;
89
       if (isset($params['word_min_length']))
87
       if (isset($params['word_min_length']))
90
       {
88
       {
94
       {
92
       {
95
         if (strlen($word) >= $word_min_length)
93
         if (strlen($word) >= $word_min_length)
96
         {
94
         {
97
-          $where_string = ($is_where) ? ' AND (' : ' WHERE (';
98
-          $is_where = true;
99
-          if ($where_string === ' AND (' || $where_string === ' WHERE (')
95
+          if ($where_string === '')
100
           {
96
           {
97
+            $where_string = ($is_where) ? ' AND (' : ' WHERE (';
98
+            $is_where = true;
101
             $where_string .= "UPPER(e_.name) LIKE :str".$i;
99
             $where_string .= "UPPER(e_.name) LIKE :str".$i;
102
           }
100
           }
103
           else
101
           else
104
           {
102
           {
105
             $where_string .= " OR UPPER(e_.name) LIKE :str".$i;
103
             $where_string .= " OR UPPER(e_.name) LIKE :str".$i;
106
           }
104
           }
107
-          //$params_string['str'.$i] = '%'.strtoupper($word).'%';
108
           $params_ids['str'.$i] = '%'.strtoupper($word).'%';
105
           $params_ids['str'.$i] = '%'.strtoupper($word).'%';
109
         }
106
         }
110
       }
107
       }
111
       $where_string .= ')';
108
       $where_string .= ')';
112
       
109
       
113
-//      $ids_query = $this->getEntityManager()
114
-//        ->createQuery("SELECT e.id FROM MuzichCoreBundle:Element e
115
-//           $where_string
116
-//           GROUP BY e.id
117
-//           ORDER BY e.created DESC, e.id DESC
118
-//        ")->setParameters($params_string)
119
-//      ;
120
-//      
121
-//      $ids_query->setMaxResults($searcher->getCount());
122
-//      $ids_result = $ids_query->getScalarResult();
123
-//      
124
-//      $ids = array();
125
-//      foreach ($ids_result as $id_record)
126
-//      {
127
-//        $ids[] = $id_record['id'];
128
-//      }
129
-//      
130
-//      if (count($ids))
131
-//      {
132
-//        if (($id_limit = $searcher->getIdLimit()))
133
-//        {
134
-//          $this->getSelectElementForSearchQuery($params_select, $user_id, $ids, $id_limit);
135
-//        }
136
-//        return $this->getSelectElementForSearchQuery($params_select, $user_id, $ids);
137
-//      }
138
-//      return $query = $this->getEntityManager()
139
-//        ->createQuery("SELECT e FROM MuzichCoreBundle:Element e WHERE 1 = 2")
140
-//      ;
141
     }
110
     }
142
     
111
     
143
     
112
     

+ 10 - 0
src/Muzich/CoreBundle/Tests/Controller/MynetworkControllerTest.php View File

79
     
79
     
80
     $this->exist('span.element_name:contains("Ed Cox - La fanfare des teuffeurs (Hardcordian)")');
80
     $this->exist('span.element_name:contains("Ed Cox - La fanfare des teuffeurs (Hardcordian)")');
81
     $this->exist('span.element_name:contains("Acrotek Hardtek G01")');
81
     $this->exist('span.element_name:contains("Acrotek Hardtek G01")');
82
+    
83
+    // On cherche des éléments en jouant avec le principe de découpe (' ', ',' '-' ...)
84
+    $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
85
+    $form['form[string]'] = 'azyd babylon cox';
86
+    $this->submit($form);
87
+    $this->isResponseSuccess();
88
+    
89
+    $this->exist('span.element_name:contains("Ed Cox - La fanfare des teuffeurs (Hardcordian)")');
90
+    $this->exist('span.element_name:contains("Babylon Pression - Des Tasers et des Pauvres")');
91
+    $this->exist('span.element_name:contains("AZYD AZYLUM Live au Café Provisoire")');
82
   }
92
   }
83
   
93
   
84
   /**
94
   /**