php search on a partial IP address stored in mysql as unsigned int -
php search on a partial IP address stored in mysql as unsigned int -
i have mysql db includes ip addresses. on search form, client wants search on partial ip address , have (perhaps) many results pop up. storing ip addresses in mysql unsigned int. using php 5.2, not have access php 5.7 , inet6_ntoa function.
the current db has on 50,000 records , continues grow, don't want have convert ip's dotted notation, match - seems bit unwieldy.
is there improve way me search on partial ip address? client insistent on this, there no choice.
ps. i'm displaying info in datatables-1.10 shouldn't have way searching - fyi.
assuming dealing ipv4 addresses, each address nil 32 bits.
there mysql inet_ntoa
function responsible homecoming string ip.
so, might want utilize smth like:
select ... ... inet_ntoa(...) (...)
hope helps.
upd: increment productivity suggest update table adding new char(16)
field string representation of ip , trigger on update
fill field inet_ntoa(...)
value. selecting against field work charm.
php mysql datatables-1.10
Comments
Post a Comment