Guest User

Untitled

a guest
Nov 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2. /*
  3. ** Plugin Name: ***
  4. ** Plugin URI: ***
  5. ** Description: ***
  6. ** Author: ***
  7. ** Version: ***
  8. */
  9.  
  10.  
  11. class Database_plugin {
  12.  
  13. static function riverfisher_add_db_tables_activation()
  14. {
  15.  
  16. global $wpdb;
  17. global $wp_users;
  18. $table_registreringer = $wpdb->prefix . 'registreringer';
  19. $charset_collate = utf8mb4_unicode_ci;
  20.  
  21. if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_registreringer}'" ) != $table_registreringer ) {
  22.  
  23. $sql = "CREATE TABLE $table_registreringer
  24. (
  25. reg_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  26. dato date,
  27. billedeURL VARCHAR(80) NOT NULL,
  28. fiske_vaegt DECIMAL( 2,1 ) NOT NULL,
  29. fiske_laengde INT NOT NULL,
  30. reg_user_id BIGINT UNSIGNED NOT NULL,
  31. reg_redskabs_id INT UNSIGNED NOT NULL,
  32. reg_koen_id INT UNSIGNED NOT NULL,
  33. reg_fisk_id INT UNSIGNED NOT NULL,
  34. reg_laks_id INT UNSIGNED NOT NULL,
  35. reg_cr_id INT UNSIGNED NOT NULL,
  36. PRIMARY KEY (reg_id),
  37. FOREIGN KEY (reg_user_id) REFERENCES wp_users(id)
  38. )
  39. COLLATE $charset_collate";
  40. echo $wpdb->last_error;
  41.  
  42. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  43. dbDelta( $sql );
  44. };
  45.  
  46. register_activation_hook( __FILE__, array( 'Database_plugin' , 'riverfisher_add_db_tables_activation' ) );
  47. ?>
Add Comment
Please, Sign In to add comment