Code Duplication    Length = 34-34 lines in 2 locations

application/modules/search/search.php 2 locations

@@ 300-333 (lines=34) @@
297
        }
298
299
        // begin query
300
        if (count($where) > 0) {
301
            foreach ($where as $params) {
302
                // Set search operator. (where, like, or_where, etc..)
303
                if (isset($params['operator'])) {
304
                    $operator = strtolower($params['operator']);
305
                    unset($params['operator']);
306
                } else {
307
                    $operator = $this->default_operator;
308
                }
309
310
                // Protect field names with backticks.
311
                if (isset($params['backticks'])) {
312
                    $backticks = $params['backticks'];
313
                    unset($params['backticks']);
314
                } else {
315
                    $backticks = TRUE;
316
                }
317
318
                if (isset($params['group']) AND $params['group'] == TRUE) {
319
                    $use_group = TRUE;
320
                    unset($params['group']);
321
                } else {
322
                    $use_group = FALSE;
323
                }
324
325
                foreach ($params as $key => $val) {
326
                    if ($use_group == FALSE) {
327
                        $this->db->$operator($key, $val, $backticks);
328
                    } else {
329
                        $this->db->where($val);
330
                    }
331
                }
332
            }
333
        }
334
335
        // Set order_by params
336
        if (count($this->order_by) > 0) {
@@ 382-415 (lines=34) @@
379
380
    private function countSearchResults($where) {
381
        // begin query
382
        if (count($where) > 0) {
383
            foreach ($where as $params) {
384
                // Set search operator. (where, like, or_where, etc..)
385
                if (isset($params['operator'])) {
386
                    $operator = strtolower($params['operator']);
387
                    unset($params['operator']);
388
                } else {
389
                    $operator = $this->default_operator;
390
                }
391
392
                // Protect field names with backticks.
393
                if (isset($params['backticks'])) {
394
                    $backticks = $params['backticks'];
395
                    unset($params['backticks']);
396
                } else {
397
                    $backticks = TRUE;
398
                }
399
400
                if (isset($params['group']) AND $params['group'] == TRUE) {
401
                    $use_group = TRUE;
402
                    unset($params['group']);
403
                } else {
404
                    $use_group = FALSE;
405
                }
406
407
                foreach ($params as $key => $val) {
408
                    if ($use_group == FALSE) {
409
                        $res = $this->db->$operator($key, $val, $backticks);
410
                    } else {
411
                        $res = $this->db->where($val);
412
                    }
413
                }
414
            }
415
        }
416
417
        return $res->get($this->table);
418
    }