Code Duplication    Length = 29-30 lines in 2 locations

Sources/DbPackages-mysql.php 1 location

@@ 459-488 (lines=30) @@
456
	// Better exist!
457
	$indexes = $smcFunc['db_list_indexes']($table_name, true);
458
459
	foreach ($indexes as $index)
460
	{
461
		// If the name is primary we want the primary key!
462
		if ($index['type'] == 'primary' && $index_name == 'primary')
463
		{
464
			// Dropping primary key?
465
			$smcFunc['db_query']('', '
466
				ALTER TABLE ' . $table_name . '
467
				DROP PRIMARY KEY',
468
				array(
469
					'security_override' => true,
470
				)
471
			);
472
473
			return true;
474
		}
475
		if ($index['name'] == $index_name)
476
		{
477
			// Drop the bugger...
478
			$smcFunc['db_query']('', '
479
				ALTER TABLE ' . $table_name . '
480
				DROP INDEX ' . $index_name,
481
				array(
482
					'security_override' => true,
483
				)
484
			);
485
486
			return true;
487
		}
488
	}
489
490
	// Not to be found ;(
491
	return false;

Sources/DbPackages-postgresql.php 1 location

@@ 605-633 (lines=29) @@
602
	if ($index_name != 'primary')
603
		$index_name = $table_name . '_' . $index_name;
604
605
	foreach ($indexes as $index)
606
	{
607
		// If the name is primary we want the primary key!
608
		if ($index['type'] == 'primary' && $index_name == 'primary')
609
		{
610
			// Dropping primary key is odd...
611
			$smcFunc['db_query']('', '
612
				ALTER TABLE ' . $table_name . '
613
				DROP CONSTRAINT ' . $index['name'],
614
				array(
615
					'security_override' => true,
616
				)
617
			);
618
619
			return true;
620
		}
621
		if ($index['name'] == $index_name)
622
		{
623
			// Drop the bugger...
624
			$smcFunc['db_query']('', '
625
				DROP INDEX ' . $index_name,
626
				array(
627
					'security_override' => true,
628
				)
629
			);
630
631
			return true;
632
		}
633
	}
634
635
	// Not to be found ;(
636
	return false;