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
- Consuming an external API in WordPress?
- How can I import a class privately into a plugin?
- Plugins or Tutorials for displaying data from SQL-db on WP-page? [closed]
- How to Loop Plugin Option Field Set?
- Custom database or Custom Post Types?
- How can I execute some small piece of PHP code in a sandbox area of my WP?
- How to Create a Directory in a Plugin Folder?
- Activating a single plugin via php
- Get the last post ID
- How to count number of records found in a database table?
- Create plugin that works in background
- Checking for user role in a custom plugin
- HELP: Integrating WP with raw PHP code once published button is hit
- How to redirect Old Post URL to new Post and keep Old post Comments?
- jQuery function didn’t work in my plugin
- bulk change of image setting “link to” to “link to: image url “
- Add category to body class
- Plugin Development sqlite or WordPress’ database
- How to review WordPress website php version compatibility?
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Where does WordPress store plugin (enabled/disabled) status for multisite?
- woocommerce 3.2.1 not sending order notification emails
- WordPress on AWS with ELB
- Executing my function once on a specific time
- custom user tables supported in SharDB plugin?
- Add a CSS class based on categroy id to archive pages
- WooCommerce: Building a page with user input which is used to query order status and external API and return a result
- Problem with PHP wordpress, Undefined index: in C:\xampp\htdocs\wordpress\wp-content\plugins\epoch\classes\core.php on line 190 [closed]
- After upgrade to php 7 plugin/them updates broke [closed]
- WordPress Integration with Google Groups
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- Activate my plugins via FTP
- How to insert and call new data in wordpress website database through a plugin
- How to add apply_filter for a class property in plugin
- A server-side hook failed when committing plugin code to SVN
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- Need to replace Currency Shortforms
- How retreive saved data from gravity forms in my template?
- Api external with wordpress
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- How to use printf to output two links?
- File Uploader – Upload without adding to Media Library
- Building a plugin into a theme
- 2 wordpress site same database
- Trying to include files in plugin isn’t working
- implement custom roles in custom plugin
- How to get current cart values using WC_Shortcodes?
- How to authorize viewing and clicking a function only logged users?
- WordPress is redirecting me to homepage
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- How to arrange custom posts in the backend/admin by custom taxonomy
- How to ignore fields if empty?
- Why is my shortcode not working?
- implement checkbox or toggle switch in plugin code
- Custom Field used to allow a Free Story; no longer works
- Admin login substantially slower on production server
- redirect to a custom page
- GET web api method from a WordPress PHP script
- How to change text in a page by utilizing a custom user id?
- Adding link on title its in description but not in title see screenshots attached
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Save selectlist value (taxonomy) in wp:wp_set_object_terms
- Page doesn’t load
- Metabox Data not saving
- Xml output not places where i want
- Including a PHP file via a function that is part of a plugin?
- How to fix ‘Call to undefined function do_settings()’ error?
- Updating WordPress [closed]
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Translate text for empty product
- Passing an input variable through a switch statement
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Posts in Admin only display 1 Post instead of all Post in admin area
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- WordPress issue – data is not showing in wp-admin, but when searching through database, all the data is there
- WordPress Throwing Deprecated Errors on its own Files