Code Duplication    Length = 45-45 lines in 2 locations

src/dbo/records.php 2 locations

@@ 451-495 (lines=45) @@
448
449
                            break;
450
451
                        case FIELD_TYPE_STRING:
452
453
                            if (is_null($row['param1']))
454
                            {
455
                                array_push($clause_filter,
456
                                           'r.record_id in ' .
457
                                           '(select e.record_id ' .
458
                                           'from tbl_events e, tbl_field_values fv ' .
459
                                           'where fv.event_id = e.event_id and ' .
460
                                           'fv.field_id = ' . $row['field_id'] . ' and ' .
461
                                           'fv.value_id is null and ' .
462
                                           'fv.is_latest = 1)');
463
                            }
464
                            else
465
                            {
466
                                switch (DATABASE_DRIVER)
467
                                {
468
                                    case DRIVER_MYSQL50:
469
                                        $concat = "concat('%', sf.string_value, '%')";
470
                                        break;
471
                                    case DRIVER_ORACLE9:
472
                                        $concat = "concat(concat('%', sf.string_value), '%')";
473
                                        break;
474
                                    case DRIVER_MSSQL2K:
475
                                        $concat = "'%' + sf.string_value + '%'";
476
                                        break;
477
                                    case DRIVER_PGSQL80:
478
                                        $concat = "'%' || sf.string_value || '%'";
479
                                        break;
480
                                    default: ;  // nop
481
                                }
482
483
                                array_push($clause_filter,
484
                                           'r.record_id in ' .
485
                                           '(select e.record_id ' .
486
                                           'from tbl_events e, tbl_field_values fv, tbl_string_values sv, tbl_string_values sf ' .
487
                                           'where fv.event_id = e.event_id and ' .
488
                                           'fv.field_id = ' . $row['field_id'] . ' and ' .
489
                                           'fv.value_id = sv.value_id and ' .
490
                                           'sf.value_id = ' . $row['param1'] . ' and ' .
491
                                           'sv.string_value like ' . $concat . ' and ' .
492
                                           'fv.is_latest = 1)');
493
                            }
494
495
                            break;
496
497
                        case FIELD_TYPE_MULTILINED:
498
@@ 497-541 (lines=45) @@
494
495
                            break;
496
497
                        case FIELD_TYPE_MULTILINED:
498
499
                            if (is_null($row['param1']))
500
                            {
501
                                array_push($clause_filter,
502
                                           'r.record_id in ' .
503
                                           '(select e.record_id ' .
504
                                           'from tbl_events e, tbl_field_values fv ' .
505
                                           'where fv.event_id = e.event_id and ' .
506
                                           'fv.field_id = ' . $row['field_id'] . ' and ' .
507
                                           'fv.value_id is null and ' .
508
                                           'fv.is_latest = 1)');
509
                            }
510
                            else
511
                            {
512
                                switch (DATABASE_DRIVER)
513
                                {
514
                                    case DRIVER_MYSQL50:
515
                                        $concat = "concat('%', sf.string_value, '%')";
516
                                        break;
517
                                    case DRIVER_ORACLE9:
518
                                        $concat = "concat(concat('%', sf.string_value), '%')";
519
                                        break;
520
                                    case DRIVER_MSSQL2K:
521
                                        $concat = "'%' + sf.string_value + '%'";
522
                                        break;
523
                                    case DRIVER_PGSQL80:
524
                                        $concat = "'%' || sf.string_value || '%'";
525
                                        break;
526
                                    default: ;  // nop
527
                                }
528
529
                                array_push($clause_filter,
530
                                           'r.record_id in ' .
531
                                           '(select e.record_id ' .
532
                                           'from tbl_events e, tbl_field_values fv, tbl_text_values tv, tbl_string_values sf ' .
533
                                           'where fv.event_id = e.event_id and ' .
534
                                           'fv.field_id = ' . $row['field_id'] . ' and ' .
535
                                           'fv.value_id = tv.value_id and ' .
536
                                           'sf.value_id = ' . $row['param1'] . ' and ' .
537
                                           'tv.text_value like ' . $concat . ' and ' .
538
                                           'fv.is_latest = 1)');
539
                            }
540
541
                            break;
542
                    }
543
                }
544
            }