Quote:
Originally Posted by TheToretto
Hey, thanks a lot for the tips, I really appreciate it, I've done everything you mentioned, ( Commit) except the datetime, do you have an example or something? And I want to keep the same actual form displayed in the dialogs, if possible.
|
Yes, it is possible:
https://dev.mysql.com/doc/refman/8.0...on_date-format
pawn Code:
SELECT IP,
DATE_FORMAT(Connected, '%%Y %%M %%e - %%T') AS Connected
FROM iplogger
WHERE Name = '%e'
Thank you for taking into consideration my suggestions. Re-consider about the use of threaded SELECT queries.
When your table does not have a primary key and searches by name, it filters about 10 percent -- it scans the whole table for looking any matches. A name cannot be unique as a player can connect more than once but a pair can be. A player joins a specific time, this pair is unique and we can also take advantage of it.
pawn Code:
CREATE TABLE `iplogger` (
`Name` varchar(24) NOT NULL,
`IP` varchar(15) NOT NULL,
`Connected` datetime NOT NULL,
`Disconnected` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`Name`,`Connected`)
)
Now it filters 100 percent.
Store unix timestamp on connect for a player and use
FROM_UNIXTIME when a player disconnects.
pawn Code:
INSERT INTO iplogger (Name, IP, Connected)
VALUES ('%s', '%s', FROM_UNIXTIME(%d))
There is one last suggestion: IPv4 can be converted to integer and take less space. If you are interested:
https://dev.mysql.com/doc/refman/8.0...tion_inet-aton
https://dev.mysql.com/doc/refman/8.0...tion_inet-ntoa
Store IP as unsigned int and the use is very simply
INET_ATON('127.0.0.1') and
INET_NTOA(IP)