Jump to content

Simple Author of News Problem


Kemik

Recommended Posts

Hello,

 

I'm making an addnews.php file. I have a form with Date, Title, Content and Author fields.

 

How would be best to store the author, by their user_id or username? Storing by username would make my life much easier and username's cannot be changed unless edited via the database.

 

Linking by user_id does have it's benefits but when I go to edit the article I won't have a clue who user 37 is unless I pull the user_id, query the database and put the username in the field. Then when updating the field query the database for the user_id of username.

 

Do you think I should go with username over user_id?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/64561-simple-author-of-news-problem/
Share on other sites

If you have to choose one of them, I'd choose the id. It just offers much more than the username, and it's not a big deal to run another query to fetch the username by the id.

But if you feel a bit lazy right now, how about them both? Then you can have the flexibility the id offers and the simplicity of the username :) This way in the future you will able to upgrade your scripts much more easily.

 

Orio.

Ids are stored as primary keys so your queries would be a bit faster. Also the main advantage of selecting ids is that ure sure that record will be unique. I'd suggest going for the ids and when u edit an article, another query wont do nothing, espacially if it will be for the back end system which wont have so much traffic as the front ent.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.