我的外键引用有什么问题?是否未创建此表?
<?php
/*
** Plugin Name: ***
** Plugin URI: ***
** Description: ***
** Author: ***
** Version: ***
*/
class Database_plugin {
static function riverfisher_add_db_tables_activation()
{
global $wpdb;
global $wp_users;
$table_registreringer = $wpdb->prefix . \'registreringer\';
$charset_collate = utf8mb4_unicode_ci;
if ( $wpdb->get_var( "SHOW TABLES LIKE \'{$table_registreringer}\'" ) != $table_registreringer ) {
$sql = "CREATE TABLE $table_registreringer
(
reg_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
dato date,
billedeURL VARCHAR(80) NOT NULL,
fiske_vaegt DECIMAL( 2,1 ) NOT NULL,
fiske_laengde INT NOT NULL,
reg_user_id BIGINT UNSIGNED NOT NULL,
reg_redskabs_id INT UNSIGNED NOT NULL,
reg_koen_id INT UNSIGNED NOT NULL,
reg_fisk_id INT UNSIGNED NOT NULL,
reg_laks_id INT UNSIGNED NOT NULL,
reg_cr_id INT UNSIGNED NOT NULL,
PRIMARY KEY (reg_id),
FOREIGN KEY (reg_user_id) REFERENCES wp_users(id)
)
COLLATE $charset_collate";
echo $wpdb->last_error;
require_once( ABSPATH . \'wp-admin/includes/upgrade.php\' );
dbDelta( $sql );
};
register_activation_hook( __FILE__, array( \'Database_plugin\' , \'riverfisher_add_db_tables_activation\' ) );
?>