|
@@ -62,7 +62,11 @@ class ElementRepository extends EntityRepository
|
62
|
62
|
return $this->getSelectElementForSearchQuery($params_select, $user_id, $searcher->getIds(), null, null, $searcher->getIdsDisplay());
|
63
|
63
|
}
|
64
|
64
|
|
|
65
|
+ // Booléen nous permettant de savoir si un where a déjà été écrit
|
|
66
|
+ $is_where = false;
|
|
67
|
+
|
65
|
68
|
// Si c'est une recherche string, les autres paramètres ne sont pas nécéssaire
|
|
69
|
+ $where_string = '';
|
66
|
70
|
if (($string = $searcher->getString()))
|
67
|
71
|
{
|
68
|
72
|
// On prépare notre liste de mots
|
|
@@ -79,8 +83,8 @@ class ElementRepository extends EntityRepository
|
79
|
83
|
));
|
80
|
84
|
|
81
|
85
|
// On récupère les ids des elements correspondants
|
82
|
|
- $where_string = "WHERE 1 = 2";
|
83
|
|
- $params_string = array();
|
|
86
|
+ //$where_string = "WHERE 1 = 2";
|
|
87
|
+ //$params_string = array();
|
84
|
88
|
$word_min_length = 0;
|
85
|
89
|
if (isset($params['word_min_length']))
|
86
|
90
|
{
|
|
@@ -90,44 +94,53 @@ class ElementRepository extends EntityRepository
|
90
|
94
|
{
|
91
|
95
|
if (strlen($word) >= $word_min_length)
|
92
|
96
|
{
|
93
|
|
- if ($where_string === "WHERE 1 = 2")
|
|
97
|
+ $where_string = ($is_where) ? ' AND (' : ' WHERE (';
|
|
98
|
+ $is_where = true;
|
|
99
|
+ if ($where_string === ' AND (' || $where_string === ' WHERE (')
|
94
|
100
|
{
|
95
|
|
- $where_string = " WHERE UPPER(e.name) LIKE :str".$i;
|
|
101
|
+ $where_string .= "UPPER(e_.name) LIKE :str".$i;
|
96
|
102
|
}
|
97
|
103
|
else
|
98
|
104
|
{
|
99
|
|
- $where_string .= " OR UPPER(e.name) LIKE :str".$i;
|
|
105
|
+ $where_string .= " OR UPPER(e_.name) LIKE :str".$i;
|
100
|
106
|
}
|
101
|
|
- $params_string['str'.$i] = '%'.strtoupper($word).'%';
|
|
107
|
+ //$params_string['str'.$i] = '%'.strtoupper($word).'%';
|
|
108
|
+ $params_ids['str'.$i] = '%'.strtoupper($word).'%';
|
102
|
109
|
}
|
103
|
110
|
}
|
|
111
|
+ $where_string .= ')';
|
104
|
112
|
|
105
|
|
- $ids_result = $this->getEntityManager()
|
106
|
|
- ->createQuery("SELECT e.id FROM MuzichCoreBundle:Element e
|
107
|
|
- $where_string
|
108
|
|
- GROUP BY e.id
|
109
|
|
- ORDER BY e.created DESC, e.id DESC
|
110
|
|
- ")->setParameters($params_string)->getScalarResult()
|
111
|
|
- ;
|
112
|
|
- $ids = array();
|
113
|
|
- foreach ($ids_result as $id_record)
|
114
|
|
- {
|
115
|
|
- $ids[] = $id_record['id'];
|
116
|
|
- }
|
117
|
|
-
|
118
|
|
- if (count($ids))
|
119
|
|
- {
|
120
|
|
- return $this->getSelectElementForSearchQuery($params_select, $user_id, $ids);
|
121
|
|
- }
|
122
|
|
- return $query = $this->getEntityManager()
|
123
|
|
- ->createQuery("SELECT e FROM MuzichCoreBundle:Element e WHERE 1 = 2")
|
124
|
|
- ;
|
|
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
|
+// ;
|
125
|
141
|
}
|
126
|
142
|
|
127
|
143
|
|
128
|
|
- // Booléen nous permettant de savoir si un where a déjà été écrit
|
129
|
|
- $is_where = false;
|
130
|
|
-
|
131
|
144
|
// Construction des conditions pour la selection d'ids
|
132
|
145
|
$where_tags = '';
|
133
|
146
|
$join_tags = '';
|
|
@@ -312,8 +325,9 @@ class ElementRepository extends EntityRepository
|
312
|
325
|
$where_user
|
313
|
326
|
$where_group
|
314
|
327
|
$where_favorite
|
315
|
|
- $where_id_limit
|
316
|
328
|
$where_tag_strict
|
|
329
|
+ $where_string
|
|
330
|
+ $where_id_limit
|
317
|
331
|
GROUP BY e_.id
|
318
|
332
|
$order_by")
|
319
|
333
|
->setParameters($params_ids)
|
|
@@ -353,7 +367,7 @@ class ElementRepository extends EntityRepository
|
353
|
367
|
}
|
354
|
368
|
|
355
|
369
|
protected function getSelectElementForSearchQuery($params_select, $user_id, $ids, $id_limit = null, $count_limit = null, $ids_display = null)
|
356
|
|
- {
|
|
370
|
+ {
|
357
|
371
|
$where = "";
|
358
|
372
|
if ($id_limit)
|
359
|
373
|
{
|