You can handle both directions using MySQL functions, i.e. when writing the 
value and reading it. This allows any PHP code to work solely with IP addresses 
and not worry about the numeric values. So use INET_ATON when storing it (see 
docs on using expressions in Zend_Db queries) and INET_NTOA when retrieving it.

Paddy

 Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative





________________________________
From: Syncrat <[email protected]>
To: [email protected]
Sent: Sun, December 13, 2009 9:30:54 AM
Subject: [fw-general] Best practice on storing IPs with Zend_DB_Table


Hi. I was just wondering what people thought was best practice on storing IPs
with Zend_DB_Table. As I understand IPs are best stored in MySQL in an
INT(11) field for faster lookups (rather than a string). If I want
zend_db_table_row to hold the string version of the ip when in memory, at
what point should the PHP ip2long function or MySQL INET_ATON function be
called. What is the best way to make this translation?
-- 
View this message in context: 
http://n4.nabble.com/Best-practice-on-storing-IPs-with-Zend-DB-Table-tp962887p962887.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to