09.05.2014, 11:32
Quote:
Use of the datetime field is up for discussion. I've always preferred regular Unix timestamps. In any case you should use UTC_TIMESTAMP() rather than NOW(). The latter one gets the local server time, which can lead to inconsistencies if migrating the server to another country (e.g. from Europe to the US) or even if trying to display data in the user's local time.
|
What I do agree on is using UTC_TIMESTAMP() or UTC_DATE() rather than NOW(), as, like you said, it guarantees the there will be no issues with the timezones.
Further reading: http://stackoverflow.com/questions/4...e-vs-timestamp
Edit: On topic:
It might be worth mentioning that the input should be escaped.
Код:
format(pQuery, sizeof(pQuery), "INSERT INTO "#TABLE_NAME"(Username, Time, Text) VALUES('%s', NOW(), '%s')", pName, text);
Код:
'); TRUNCATE TABLE `chat`; --
Another thing: You should probably use datetime field instead of date, as it would most likely be useful to store the time of the message as well, not just the date.