Database data table creation syntax:
DROP TABLE IF EXISTS' admin ';CREATE TABLE IF not EXISTS' admin ' (' Adminid ' )INTUNSIGNED not NULLAuto_increment COMMENT'primary Key ID', ' Adminuser 'VARCHAR( +) not NULL DEFAULT "'COMMENT'Administrator Account', ' AdminPass 'CHAR( +) not NULL DEFAULT "'COMMENT'Administrator Password', ' AdminEmail 'VARCHAR( -) not NULL DEFAULT "'COMMENT'Admin e-mail', ' logintime ' bigint UNSIGNED not null default Span style= "COLOR: #ff0000" > " 0 " COMMENT " logon time " , ' Loginip ' bigint not null default " 0 " COMMENT " logon IP " , ' Createtime 'INTUNSIGNED not NULL DEFAULT '0'COMMENT'creation Time', PRIMARY KEY(' Adminid '),UNIQUEadmin_adminuser_adminpass (' Adminuser ', ' AdminPass '),UNIQUEadmin_adminuser_adminemail (' Adminuser ', ' AdminEmail ')) ENGINE=InnoDBDEFAULTCHARSET=UTF8;
(1) Under MySQL console:
IP address-to-integer type :Inet_aton
mysql> updateset userip=Inet_aton ('192.168.1.1' where username='admin';
Mysql> Select * fromadmin;+---------+-----------+----------------------------------+----------------+------------+------------+--------- ---+|Adminid|Adminuser|AdminPass|AdminEmail|Logintime|Loginip|Createtime|+---------+-----------+----------------------------------+----------------+------------+------------+--------- ---+| 1 |Admin|202cb962ac59075b964b07152d234b70|Zq@zqblogs. cn| 1482500788 |3232235777| 1482419387 |+---------+-----------+----------------------------------+----------------+------------+------------+--------- ---+1Rowinch Set(0.00Sec
int-Turn IP address type :inet_ntoa
mysql> Select inet_ntoa (4294967295);
+ -- ---------------------+ | Inet_ntoa (4294967295| + -- ---------------------+ | 255.255. 255.255 | + -- ---------------------+
(2) PHP code implementation: Ip2long
Inserting an IP address into a field with a data type of int or bigint via PHP code ( syntax using the YII framework )
$this->updateall (
Time Ip2long (Yii::$app
$this->adminuser]
);
Yii:: $app->request->userip: Indicates the IP address obtained through the HTTP request header to the current user's browser (note: Available through $_server[' remote_addr ') Get to local IP address)
(Illustration 1: Use 127.0.0.1 to access the local Apache server instead of the Localhost,localhost IP:: 1, bigint type that does not conform to the database limit)
(Note 2: The IP address and domain name mappings for the Web server are configured in the C:\Windows\System32\drivers\etc\hosts file
)
Description: Reprint Please specify the source http://www.cnblogs.com/zqblogc/p/6216237.html
Friendship Reference: http://www.qttc.net/201208193.html
MySQL Storage IP address operation