Code Duplication    Length = 11-11 lines in 8 locations

system/libraries/Database.php 8 locations

@@ 472-482 (lines=11) @@
469
     * @param   boolean       automatically add starting and ending wildcards
470
     * @return  Database_Core        This Database object.
471
     */
472
    public function like($field, $match = '', $auto = true)
473
    {
474
        $fields = is_array($field) ? $field : array($field => $match);
475
476
        foreach ($fields as $field => $match) {
477
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
478
            $this->where[] = $this->driver->like($field, $match, $auto, 'AND ', count($this->where));
479
        }
480
481
        return $this;
482
    }
483
484
    /**
485
     * Selects the or like(s) for a database query.
@@ 492-502 (lines=11) @@
489
     * @param   boolean       automatically add starting and ending wildcards
490
     * @return  Database_Core        This Database object.
491
     */
492
    public function orlike($field, $match = '', $auto = true)
493
    {
494
        $fields = is_array($field) ? $field : array($field => $match);
495
496
        foreach ($fields as $field => $match) {
497
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
498
            $this->where[] = $this->driver->like($field, $match, $auto, 'OR ', count($this->where));
499
        }
500
501
        return $this;
502
    }
503
504
    /**
505
     * Selects the not like(s) for a database query.
@@ 512-522 (lines=11) @@
509
     * @param   boolean       automatically add starting and ending wildcards
510
     * @return  Database_Core        This Database object.
511
     */
512
    public function notlike($field, $match = '', $auto = true)
513
    {
514
        $fields = is_array($field) ? $field : array($field => $match);
515
516
        foreach ($fields as $field => $match) {
517
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
518
            $this->where[] = $this->driver->notlike($field, $match, $auto, 'AND ', count($this->where));
519
        }
520
521
        return $this;
522
    }
523
524
    /**
525
     * Selects the or not like(s) for a database query.
@@ 531-541 (lines=11) @@
528
     * @param   string        like value to match with field
529
     * @return  Database_Core        This Database object.
530
     */
531
    public function ornotlike($field, $match = '', $auto = true)
532
    {
533
        $fields = is_array($field) ? $field : array($field => $match);
534
535
        foreach ($fields as $field => $match) {
536
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
537
            $this->where[] = $this->driver->notlike($field, $match, $auto, 'OR ', count($this->where));
538
        }
539
540
        return $this;
541
    }
542
543
    /**
544
     * Selects the like(s) for a database query.
@@ 550-560 (lines=11) @@
547
     * @param   string        like value to match with field
548
     * @return  Database_Core        This Database object.
549
     */
550
    public function regex($field, $match = '')
551
    {
552
        $fields = is_array($field) ? $field : array($field => $match);
553
554
        foreach ($fields as $field => $match) {
555
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
556
            $this->where[] = $this->driver->regex($field, $match, 'AND ', count($this->where));
557
        }
558
559
        return $this;
560
    }
561
562
    /**
563
     * Selects the or like(s) for a database query.
@@ 569-579 (lines=11) @@
566
     * @param   string        like value to match with field
567
     * @return  Database_Core        This Database object.
568
     */
569
    public function orregex($field, $match = '')
570
    {
571
        $fields = is_array($field) ? $field : array($field => $match);
572
573
        foreach ($fields as $field => $match) {
574
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
575
            $this->where[] = $this->driver->regex($field, $match, 'OR ', count($this->where));
576
        }
577
578
        return $this;
579
    }
580
581
    /**
582
     * Selects the not regex(s) for a database query.
@@ 588-598 (lines=11) @@
585
     * @param   string        regex value to match with field
586
     * @return  Database_Core        This Database object.
587
     */
588
    public function notregex($field, $match = '')
589
    {
590
        $fields = is_array($field) ? $field : array($field => $match);
591
592
        foreach ($fields as $field => $match) {
593
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
594
            $this->where[] = $this->driver->notregex($field, $match, 'AND ', count($this->where));
595
        }
596
597
        return $this;
598
    }
599
600
    /**
601
     * Selects the or not regex(s) for a database query.
@@ 607-617 (lines=11) @@
604
     * @param   string        regex value to match with field
605
     * @return  Database_Core        This Database object.
606
     */
607
    public function ornotregex($field, $match = '')
608
    {
609
        $fields = is_array($field) ? $field : array($field => $match);
610
611
        foreach ($fields as $field => $match) {
612
            $field         = (strpos($field, '.') !== false) ? $this->config['table_prefix'].$field : $field;
613
            $this->where[] = $this->driver->notregex($field, $match, 'OR ', count($this->where));
614
        }
615
616
        return $this;
617
    }
618
619
    /**
620
     * Chooses the column to group by in a select query.