|
@@ 691-704 (lines=14) @@
|
| 688 |
|
* 'VARCHAR(10)' |
| 689 |
|
* @return bool|int |
| 690 |
|
*/ |
| 691 |
|
public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
| 692 |
|
if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
| 693 |
|
return FALSE; |
| 694 |
|
} |
| 695 |
|
global $wpdb; |
| 696 |
|
$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
| 697 |
|
$fields = self::get_fields_on_table($table_name); |
| 698 |
|
if (!in_array($column_name, $fields)){ |
| 699 |
|
$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
| 700 |
|
//echo "alter query:$alter_query"; |
| 701 |
|
return $wpdb->query($alter_query); |
| 702 |
|
} |
| 703 |
|
return TRUE; |
| 704 |
|
} |
| 705 |
|
|
| 706 |
|
|
| 707 |
|
|
|
@@ 801-815 (lines=15) @@
|
| 798 |
|
* @param string $index_name |
| 799 |
|
* @return bool | int |
| 800 |
|
*/ |
| 801 |
|
public static function drop_index( $table_name, $index_name ) { |
| 802 |
|
if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
| 803 |
|
return FALSE; |
| 804 |
|
} |
| 805 |
|
global $wpdb; |
| 806 |
|
$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
| 807 |
|
$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
| 808 |
|
if ( |
| 809 |
|
EEH_Activation::table_exists( $table_name ) |
| 810 |
|
&& $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name |
| 811 |
|
) { |
| 812 |
|
return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
| 813 |
|
} |
| 814 |
|
return TRUE; |
| 815 |
|
} |
| 816 |
|
|
| 817 |
|
|
| 818 |
|
|