Code Duplication    Length = 23-23 lines in 2 locations

engine/classes/Elgg/Database/MetadataTable.php 1 location

@@ 663-685 (lines=23) @@
660
					$value = $this->db->sanitizeString($pair['value']);
661
				} else if (is_bool($pair['value'])) {
662
					$value = (int)$pair['value'];
663
				} else if (is_array($pair['value'])) {
664
					$values_array = array();
665
	
666
					foreach ($pair['value'] as $pair_value) {
667
						if (is_numeric($pair_value) && !in_array($num_test_operand, $num_safe_operands)) {
668
							$values_array[] = $this->db->sanitizeString($pair_value);
669
						} else {
670
							$values_array[] = "'" . $this->db->sanitizeString($pair_value) . "'";
671
						}
672
					}
673
	
674
					if ($values_array) {
675
						$value = '(' . implode(', ', $values_array) . ')';
676
					}
677
	
678
					// @todo allow support for non IN operands with array of values.
679
					// will have to do more silly joins.
680
					$operand = 'IN';
681
				} else if ($trimmed_operand == 'in') {
682
					$value = "({$pair['value']})";
683
				} else {
684
					$value = "'" . $this->db->sanitizeString($pair['value']) . "'";
685
				}
686
	
687
				$name = $this->db->sanitizeString($pair['name']);
688
	

engine/classes/Elgg/Database/PrivateSettingsTable.php 1 location

@@ 239-261 (lines=23) @@
236
				// if the operand is IN don't quote it because quoting should be done already.
237
				if (is_numeric($pair['value'])) {
238
					$value = $this->db->sanitizeString($pair['value']);
239
				} else if (is_array($pair['value'])) {
240
					$values_array = array();
241
242
					foreach ($pair['value'] as $pair_value) {
243
						if (is_numeric($pair_value)) {
244
							$values_array[] = $this->db->sanitizeString($pair_value);
245
						} else {
246
							$values_array[] = "'" . $this->db->sanitizeString($pair_value) . "'";
247
						}
248
					}
249
250
					if ($values_array) {
251
						$value = '(' . implode(', ', $values_array) . ')';
252
					}
253
254
					// @todo allow support for non IN operands with array of values.
255
					// will have to do more silly joins.
256
					$operand = 'IN';
257
				} else if ($trimmed_operand == 'in') {
258
					$value = "({$pair['value']})";
259
				} else {
260
					$value = "'" . $this->db->sanitizeString($pair['value']) . "'";
261
				}
262
263
				$name = $this->db->sanitizeString($name_prefix . $pair['name']);
264