-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Timwi wrote:
Greg Sabino Mullane wrote:
A member variable avoids putting in any ugly "if db == postgres" lines, and allows easy future handling of other date issues. I'm not sure what function you are saying should be overridden?
I believe the idea is to have separate _classes_ for each DB system, so "db == postgres" would not be necessary because you'd have a separate class for PostgreSQL. In that class, you should simply override the function realTimestamps() and plainly return true. That would be proper object-oriented design, and it's a very common practice.
Yep. :)
Since we've already got those separate classes, the sensible and readable thing is for the method to simply return the correct value for its own class, rather than schlepping around a member variable that never changes.
Greg Sabino Mullane wrote:
- Consider simply fixing the code to properly validate input and
produce portable output, the way it's supposed to.
There should be no need to check or care what internal format the database uses when dealing with form parameters.
Not clear what you mean here. Since the internal format determines the range of valid form input, the only other way to do it is to convert the timestamp to epoch, output that, and then make sure we convert it back after the validation but before it is passed to any queries (or make alternative queries).
Yes, exactly. This is how all other web I/O is done, including other uses of timestamps.
The wfTimestamp() performs normalization of all known input formats to a requested format for either internal processing or output.
The TS_MW format is used in most cases for web I/O; it's also used for timestamp fields with the current MySQL classes, but you never need to know that since it's encapsulated in the Database->timestamp() method.
Sometimes other formats are used for particular protocols that prefer some normalized date format.
- -- brion vibber (brion @ pobox.com)