Add the autoincrement
keyword after `id` int NOT NULL
:
public static function activate() {
global $wpdb;
$sql = "CREATE TABLE `{$wpdb->base_prefix}employee` (
`id` int NOT NULL autoincrement,
`name` varchar(255) NOT NULL,
`dob` date NOT NULL,
`gender` int NOT NULL,
`email` varchar(255) NOT NULL,
`joining_date` date NOT NULL,
`address` varchar(255) NOT NULL,
`salary_package` int NOT NULL,
`marital_status` int NOT NULL,
`department` varchar(255) NOT NULL,
`designation` varchar(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci AUTO_INCREMENT=1;
COMMIT;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
Related Posts:
- How to properly insert data into custom table via plugin
- Simple form that saves to database
- How to store ACF custom fields data in a custom table
- How to edit/delete single row items in a table on my own menu page
- Get total number of comment of the posts written by an author
- How to write one comment and publish on every post using database or plugin?
- How to access data in wordpress database externally using php
- Creating a CSV with PHP inside the plugin directory
- Issue running db create table query from static method
- How to create plugin/ page that reads from database
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- Is this plugin safe to run?
- How to display results from a data table with an encrypted user id?
- add_action for publish_post doesn’t work
- Getting URL GET parameter with Code snippets and storing it in database?
- Cant create table on plugin activation
- How to use WordPress header function and footer function and not load word press database
- Get Shortcode output to database for static post_content
- Moving a few select DB tables to a new WP instance
- How can I store user preferences in WordPress and retreive them later?
- How to save information related to post in database?
- plugin doesn’t retrieve data from database
- can not serialize and insert data from custom form
- How can you call to data in google sheet based on ID number?
- Creating Tables on Network Activation
- Missing argument 3 for wp_register_sidebar_widget()
- How to Include a Loop Template File in a Plugin
- Write to / remove from default .htaccess file from plugin?
- What kind of data is that?
- Update Option Error: Notice: Undefined index
- How can I display a contact form for out of stock products in WooCommerce?
- Pass a php string to a javascript variable
- get shortcode value
- Cannot login to ADMIN even after changing password in phpmyadmin
- How to get number of Affected rows from wordpress dbDelta() function
- Unable to create new database table upon plugin activation using dbDelta
- Show price with Geo IP location
- Where to hook my plugin’s action
- WordPress Ajax Callback
- Add category to body class
- The called constructor method for WP_Widget in GFWidget is deprecated since version 4.3.0! Use
- Plugin Development sqlite or WordPress’ database
- How to review WordPress website php version compatibility?
- printf – problem to understand code
- Custom Post Type Plugin not loading category template and loading 404 instead
- Embed a Google Sheet as you view it in a separate tab?
- Sending email from inside a plugin using PHP PEAR
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- How to determine what is generating large amount of database queries?
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to trigger $_GET request within admin plugin page?
- Wp favorite posts get user favorites in profile using buddypress [closed]
- Storing Options in a Shortcode
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- Building an email signup form. Where should the information be saved in the DB?
- How to generate video out of images via WordPress plugin
- Saving Custom Post types and fields to a custom table
- Retrieving a Value from a wp-database
- How can I get WordPress to save comments in markdown format?
- Need help restoring my WordPress blog
- add_query_arg not working
- problems with wordpress and php version 5.3.3-1
- WP plugins for building a database?
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- Open Post Thumbnail in New Child Theme File in WordPress
- add mediaelement.js plugins into WordPress video player control bar
- Shortcode button dosent work for all posts. Work for first post only
- Where does WordPress store plugin (enabled/disabled) status for multisite?
- Where should I save an API key of my user when installing my plugin?
- Prevent a plugin from being automatically activated
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Accessing post’s meta data based on user’s click of a post
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- Preferred way of cacheing a value in php
- Redirecting to home page after login as custom role WordPress
- WordPress Redirect Not Working – AJAX Callback Response Not Picked Up
- How to Use Parameters with a Do_Action Function Within PHP Tags
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- How to remove html code in excel downloads using phpspreadsheet with wordpress plugins shortcode
- Add Product Subtitle to Woocommerce Product Page
- Self deactivate plugins after an action occurs
- wp_redirect() not working in Insert PHP plugin in WordPress
- Download any file after submitting a form [closed]
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- woocommerce 3.2.1 not sending order notification emails
- WordPress takes too much time (100 seconds) to load – Front end and back end
- When to use action hooks and plugins
- WordPress on AWS with ELB
- Saving changes in wp_editor
- Executing my function once on a specific time
- Set Post Format if find a string in title or post content
- Display data on Word Press site posts and pages from mysql table
- Notepad sticky plugin
- Output array into one table cell
- Plugin Options Not Saving to Database in WP 4.5
- WooCommerce Custom Product to checkout