Created
July 22, 2019 20:15
-
-
Save yaleksandr89/40f6a3e3bd761084cae0f50790bb8435 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Создание | |
| function create_custom_table() | |
| { | |
| global $wpdb; | |
| require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| $table_name = $wpdb->prefix . 'test_table'; | |
| $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset} COLLATE {$wpdb->collate}"; | |
| $sql = "CREATE TABLE {$table_name} ( | |
| id bigint(20) unsigned NOT NULL auto_increment, | |
| address varchar(255) NOT NULL default '', | |
| alert varchar(20) NOT NULL default '', | |
| meta longtext NOT NULL default '', | |
| PRIMARY KEY (id), | |
| KEY alert (alert) | |
| ) | |
| {$charset_collate}"; | |
| dbDelta($sql); | |
| } | |
| create_custom_table(); | |
| // Создание | |
| function drop_custom_table() | |
| { | |
| global $wpdb; | |
| $table_name = $wpdb->prefix . 'test_table'; | |
| $wpdb->query("DROP TABLE IF EXISTS {$table_name} "); | |
| } | |
| drop_custom_table(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment