@@ -216,15 +216,44 @@ private function buildSQL(){
216
216
}
217
217
return $ sql ;
218
218
}
219
+
220
+ /**
221
+ * Gets sql search query by apending AND clause.
222
+ * @return string SQL query
223
+ */
224
+ public function getAndQuery (){
225
+ return $ this ->generateQuery ("AND " );
226
+ }
227
+
228
+ /**
229
+ * Gets sql search query by apending WHERE clause.
230
+ * @return string SQL query
231
+ */
232
+ public function getWhereQuery (){
233
+ return $ this ->generateQuery ("WHERE " );
234
+ }
235
+
236
+ /**
237
+ * Gets sql search query by automatically detecting and apending start clause.
238
+ * @return string SQL query
239
+ */
240
+ public function getQuery (){
241
+ return $ this ->generateQuery ();
242
+ }
219
243
220
244
/**
221
245
* Execute search query.
246
+ * @param string $checkOpt the search query start operator
222
247
* @return string SQL query
223
248
*/
224
- public function getQuery ( ){
249
+ public function generateQuery ( $ checkOpt = " AUTO " ){
225
250
if (!empty ($ this ->searchQuery )){
226
251
if (!empty ($ this ->searchQuery )){
227
- $ this ->QueryCondition .= (!empty ($ this ->QueryCondition ) ? " AND ( " : " WHERE ( " );
252
+ if ($ checkOpt != "AUTO " && empty ($ this ->QueryCondition )){
253
+ $ this ->QueryCondition .= " {$ checkOpt } ( " ;
254
+ }else {
255
+ $ this ->QueryCondition .= (!empty ($ this ->QueryCondition ) ? " AND ( " : " WHERE ( " );
256
+ }
228
257
switch ($ this ->searchAlgorithm ){
229
258
case self ::OR :
230
259
$ this ->setStart (self ::LIKE );
0 commit comments