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).

  • 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. – kelly johnson Apr 29 '14 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 Apr 29 '14 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 Apr 29 '14 at 16:09
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, privacy policy and cookie policy

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