File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,11 @@ class SearchController{
75
75
*/
76
76
private $ queryEnd ;
77
77
78
+ /**
79
+ * @var bool Search request query in lowercase
80
+ */
81
+ private $ lowerCaseQuery = false ;
82
+
78
83
public function __construct ($ algorithm = self ::OR ) {
79
84
$ this ->searchAlgorithm = $ algorithm ;
80
85
$ this ->operators = self ::END_WITH_QUERY ;
@@ -131,6 +136,12 @@ public function setQuery($query){
131
136
$ this ->searchQuery = htmlspecialchars ($ query , ENT_QUOTES , "UTF-8 " );
132
137
return $ this ;
133
138
}
139
+
140
+ public function toLower (){
141
+ $ this ->lowerCaseQuery = true ;
142
+ $ this ->searchQuery = strtolower ($ this ->searchQuery );
143
+ return $ this ;
144
+ }
134
145
135
146
/**
136
147
* Set query prefix string.
@@ -174,7 +185,7 @@ private function format($value) {
174
185
$ queryString = "" ;
175
186
foreach ($ this ->paramArray as $ col ){
176
187
$ sqlQuery = str_replace ("query " , $ value , $ this ->operators );
177
- $ queryString .= $ col . " {$ this ->queryStart } ' {$ sqlQuery }' {$ this ->queryEnd } " ;
188
+ $ queryString .= ( $ this -> lowerCaseQuery ? " LOWER( " . $ col . " ) " : $ col ) . " {$ this ->queryStart } ' {$ sqlQuery }' {$ this ->queryEnd } " ;
178
189
}
179
190
return $ queryString ;
180
191
}
You can’t perform that action at this time.
0 commit comments