seborgarsen
Member
Posted 2 years ago #
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.
http://codex.wordpress.org/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!
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;";
seborgarsen
Member
Posted 2 years ago #
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.
seborgarsen
Member
Posted 2 years ago #
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.