• Resolved seborgarsen

    (@seborgarsen)


    Hi,

    I want to create new database table and use relation to wp_user id, just like wp_usermeta.

    How is this accomplished?

    I have been looking at wp_usermeta for the answer but have been unable to find just how the referencing is done.

    https://codex.www.ads-software.com/images/8/83/WP_27_dbsERD.png – it seems there are foreign keys in play here, but AFAIK MyISAM doesn’t support it. Highly confusing…

    Any help Highly appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Here’s the code WordPress uses to create that table:

    CREATE TABLE $wpdb->usermeta (
      umeta_id bigint(20) unsigned NOT NULL auto_increment,
      user_id bigint(20) unsigned NOT NULL default '0',
      meta_key varchar(255) default NULL,
      meta_value longtext,
      PRIMARY KEY  (umeta_id),
      KEY user_id (user_id),
      KEY meta_key (meta_key)
    ) $charset_collate;";

    Thread Starter seborgarsen

    (@seborgarsen)

    Thanks, Michael.

    Excuse me if I’m blind here, but I can’t see where the relation exists?

    I don’t believe WordPress uses the “FOREIGN KEY” clause when creating that or any table.

    Thread Starter seborgarsen

    (@seborgarsen)

    Roger that, thanks.

    I’ve managed to move ahead and now trying to write my first plugin. Trying to get my head around ajax calls in wp. I might need some help there as well.

    Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Foreign keys, referencing wp_users.id’ is closed to new replies.