Code Duplication    Length = 19-19 lines in 2 locations

engine/classes/Elgg/Database/MetadataTable.php 2 locations

@@ 551-569 (lines=19) @@
548
	
549
		// get names wheres and joins
550
		$names_where = '';
551
		if ($names !== null) {
552
			if (!is_array($names)) {
553
				$names = array($names);
554
			}
555
	
556
			$sanitised_names = array();
557
			foreach ($names as $name) {
558
				// normalise to 0.
559
				if (!$name) {
560
					$name = '0';
561
				}
562
				$sanitised_names[] = '\'' . $this->db->sanitizeString($name) . '\'';
563
			}
564
	
565
			if ($names_str = implode(',', $sanitised_names)) {
566
				$return['joins'][] = "JOIN {$this->metastringsTable->getTableName()} msn on n_table.name_id = msn.id";
567
				$names_where = "(msn.string IN ($names_str))";
568
			}
569
		}
570
	
571
		// get values wheres and joins
572
		$values_where = '';
@@ 573-591 (lines=19) @@
570
	
571
		// get values wheres and joins
572
		$values_where = '';
573
		if ($values !== null) {
574
			if (!is_array($values)) {
575
				$values = array($values);
576
			}
577
	
578
			$sanitised_values = array();
579
			foreach ($values as $value) {
580
				// normalize to 0
581
				if (!$value) {
582
					$value = 0;
583
				}
584
				$sanitised_values[] = '\'' . $this->db->sanitizeString($value) . '\'';
585
			}
586
	
587
			if ($values_str = implode(',', $sanitised_values)) {
588
				$return['joins'][] = "JOIN {$this->metastringsTable->getTableName()} msv on n_table.value_id = msv.id";
589
				$values_where = "({$binary}msv.string IN ($values_str))";
590
			}
591
		}
592
	
593
		if ($names_where && $values_where) {
594
			$wheres[] = "($names_where AND $values_where AND $access)";