acctman Posted July 24, 2008 Share Posted July 24, 2008 I have two options, either 1. create a field (user_lastip) and just do a sql UPDATE everytime the user logs in. or 2. separate table (site_logs) with user_id, user_name, user_lastip and timestamp. sql would have to do a lookup to see if they user_id exist in the "site_logs" table if not then INSERT, if it does then UPDATE. Which method is better overall for performance on a large site? Link to comment https://forums.phpfreaks.com/topic/116503-logging-ips-best-method/ Share on other sites More sharing options...
rawb Posted July 26, 2008 Share Posted July 26, 2008 If the relationship is 1:1 then I don't see any downside to just including a 'user_lastip' field in the users table. There doesn't seem like any point in making a separate table when each user only needs 1 entry anyways - only do this if you want to record each ip from which a user connects because the relationship is then 1:many. Link to comment https://forums.phpfreaks.com/topic/116503-logging-ips-best-method/#findComment-600038 Share on other sites More sharing options...
scotchegg78 Posted July 26, 2008 Share Posted July 26, 2008 Yeah why have a 2nd table for this when its still only storiing one instance per user? If you want a history of all logins then user a 2nd table, also you dont need to store the user name again, just the id which would link you ot the user table for their details. Link to comment https://forums.phpfreaks.com/topic/116503-logging-ips-best-method/#findComment-600071 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.