I have 2 SQL tables that have
- INT [post_id] INT [view_count] -> post_views table
- STR [user_ip] DateTime [date] INT [entries] -> users table
So I get user ip and check if this ip in base and it's date is outdated (1 day ago), then i update the date or ignore call, then if this ip is not in base, i add it to base and update view_count of some post from where update request with ip is come from.
Problem is that, how to check what post_id user have seen, and if this post_id have not been seen, then update it's view count value, or ignore if this user seen it that day.
How to store in user table which post_id's user have been seen in the best way? Maybe just add to user table column like viewed_posts as STR and store there post id's separated by comma? STR [viewed_id_list] -> [1,5,9]
Maybe there is better way than code/decode post id's in such new column?
I'm using php 5.4 with PDO for SQL transactrions.