note 79490 deleted from language.types.integer by cmb

From: Date: Fri, 03 Jun 2016 13:33:49 +0000
Subject: note 79490 deleted from language.types.integer by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-205656@lists.php.net to get a copy of this message
Note Submitter: autotelic at NOOOOSPAM dot hotmail dot com ---- A note about converting IP addresses for storage in database. For MySQL, this is unnecessary as it has built in support via the INET functions. Also, there is no need to use BIGINT. UNSIGNED INT is, at 4 bytes, the perfect size for holding an IP (column must be defined as UNSIGNED). This can basically halve the storage size, as BIGINT is an 8 byte data type. INET_ATON() converts a dotted IP string to INT: INSERT table(ip) VALUES(INET_ATON('127.0.0.1')); INET_NTOA() converts an INT to dotted IP string: SELECT INET_NTOA(ip) FROM table returns '127.0.0.1' Details: http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html

« previous php.notes (#205656) next »