First of all, sorry for another subject about ipv4 and ipv6. I'm still confused at some points. Let me explain.
I want to store the number of views for my articles.
To do this in a best method I need also to store the users ip in a table.
Table article_views_ip_list
with columns ip varbinary(16)
and ip_id int(11) UNSIGNED AUTO_INCREMENT
Table article_views
with columns article_id
, ip_id
(from article_views_ip_list). Here I will set uniqeu for both.
Get article views
SELECT COUNT(*) FROM article_views WHERE article_id = 123
Sounds good until here.
So, in my application I will check if IPv6 exists. If yes, it will be inserted into ip varbinary(16)
(from article_views_ip_list).
If the IPv6 doesn't exists or is not correct, I will insert the IPv4 in the same column ip varbinary(16)
(from article_views_ip_list).
I go to https://whatismyipaddress.com/ and the website gives to me:
IPv6: 2a02:2f0b:430e:1500:61ce:b1da:4a58:975
IPv4: 82.76.115.143
So, I have both available...
If I insert IPv6 into article_views_ip_list, and tomorrow (is that possible ?) I don't have anymore IPv6, then I will insert the IPv4.
So, I will have 2 ips from same user and further, SELECT COUNT(*) FROM article_views WHERE article_id = 123
will return to me more views than expected. I could say duplicates.
Can someone please clarify ?
Aucun commentaire:
Enregistrer un commentaire