Page 1 of 1
Columns for IP
Posted: Wed Jul 27, 2005 4:18 pm
by Ambush Commander
Right now, I'm storing the IP string that PHP gives you in one column `ip`. But after reading about normalization, I'm having doubts. Is there a better way to do this? And what about IPv6?
Posted: Wed Jul 27, 2005 4:22 pm
by nielsene
Some databases provide an INET or CIDR, etc datatype that is designed for dealing with IP address and/or netmasks, etc. However often they are rather broken and just using the string is acceptable.
As the majority of the uses of the IP are atomic (you aren't splitting it into its octets for most things) it doesn't require normalization.
Posted: Wed Jul 27, 2005 4:25 pm
by Ambush Commander
And suppose you wanted to 23.45.*.*, how would you go about doing that?
Posted: Wed Jul 27, 2005 4:26 pm
by nielsene
That's what the special types with netmasks/etc are for.
Posted: Wed Jul 27, 2005 4:46 pm
by Roja
I generally use strings, as that enables easy select/like searches.
Posted: Wed Jul 27, 2005 5:12 pm
by Ambush Commander
Yes, I suppose you could use RegExps.