Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dbDelta sample
<?php
global $wpdb;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$sql = "CREATE TABLE `{$wpdb->prefix}app_employees` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`post_id` BIGINT(20) DEFAULT NULL,
`emp_number` VARCHAR(20) COLLATE {$wpdb->collate} DEFAULT NULL,
`full_name` VARCHAR(100) COLLATE {$wpdb->collate} DEFAULT NULL,
`gender` VARCHAR(6) COLLATE {$wpdb->collate} DEFAULT NULL,
`birth_date` DATE DEFAULT NULL,
`email` VARCHAR(200) COLLATE {$wpdb->collate} DEFAULT NULL,
`mobile` VARCHAR(20) COLLATE {$wpdb->collate} DEFAULT NULL,
`join_date` DATE DEFAULT NULL,
`empfunction_id` INT(11) DEFAULT NULL,
`empfunction_date` DATE DEFAULT NULL,
`user_id` BIGINT(20) DEFAULT NULL,
`date_trashed` DATETIME DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB COLLATE={$wpdb->collate}; ";
dbDelta( $sql );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment