Created
August 19, 2019 10:02
-
-
Save fgrweb/af18ea12f328dc5546500b6d579b2a47 to your computer and use it in GitHub Desktop.
Snippet to create WordPress table with function dbDelta()
This file contains 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
global $wpdb; | |
$table_name = $wpdb->prefix . 'prueba_tabla'; | |
$wpdb_collate = $wpdb->collate; | |
$sql = | |
"CREATE TABLE {$table_name} ( | |
id mediumint(8) unsigned NOT NULL auto_increment , | |
nombre varchar(255) NULL, | |
PRIMARY KEY (id), | |
KEY first (nombre) | |
) | |
COLLATE {$wpdb_collate}"; | |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); | |
dbDelta( $sql ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment