0

I'm just learning this database stuff and so I am a bit confused and was hoping someone could push me in the right direction. I have managed to create users in the wp_tables I have created in my database.

enter image description here

Here are my specific questions.

  1. What I am wondering is how do I link the hm_tables with data from the wp_tables. Wouldn't I need to insert a foreign key (i.e email address from wp_users) into the hm_tables. Because, otherwise I won't know which hm_account is linked to which wp_user? Is this dumb? And if so, HOW?

  2. Also, I have become familiar with using WPDB commands, but when playing around with the hm_tables can I use $wpdb or do I need to use straight SQL commands.

Can you please give explicit instructions or examples as I get very lost at this early stage. I have read around but can't seem to find something that explains this at a level I can understand (which at this stage is quite low).

3
  • Are you using phpMyAdmin? And can I ask why are you using a different table prefix? (hm_ instead of wp_ that you apparently already have?) You do need to change your table prefix in your wp-config.php file. Commented Apr 29, 2014 at 4:16
  • I have actually managed to figure out the problem. Apparently wdpb does work with the hm_database files but I agree I should just change them. I guess my thinking was that if anyone looked at the plugin they would see what we had added.
    – Danrex
    Commented Apr 29, 2014 at 4:20
  • 99 times out of 100, creating your own tables is unnecessary. I suggest looking into custom post types + meta data to store your plugin data. you get a whole bunch of functionality for free that you will otherwise have to code yourself when using your own tables.
    – Milo
    Commented Apr 29, 2014 at 16:09

1 Answer 1

0

I would suggest to use double prefix like wp_hm_account, since it will allow you to recognize the tables (as you mentioned in comment) and you will be also able to use wpdb class properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.