nciri / zend-db-model-generator

Automatically exported from code.google.com/p/zend-db-model-generator
0 stars 0 forks source link

MySQL does not support ISO 8601 format dates #31

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In MySQL there's no time zone handling (regarding to the databases, not to the 
program itself).

That's why when the connection mode is set to strict (eg. to 
STRICT_TRANS_TABLES) the server refuses those (date)time values which contain 
time zone information (eg. +03:00) with the error message like this "Incorrect 
datetime value: '2011-01-26T09:50:44+00:00' for column 'xy' at row 1".
Probably in non-strict mode the server simply cuts the time zone information, 
so there's no use either.

Please, add "mysql" to the exception list to templates/model.tpl lines 124 and 
156.
The provided datetime string "YYYY-MM-ddTHH:mm:ss.S" seems to work for me.

Thank you.

Original issue reported on code.google.com by szots...@gmail.com on 14 Aug 2012 at 10:20

GoogleCodeExporter commented 8 years ago
There's an other problem related to this one: MySQL does not accept invalid 
dates as input.

If there's a NULL valued cell in a db table, the zdmg setFunction() in the 
model will bind "0000:00:00 00:00" invalid DATE(TIME) to the model via a 
Zend_Date constructor (model.tpl:117).

But 0000 is not a valid date and that's why Zend will convert it to a valid 
date (specifically to "00-1-11-30"). This date is valid, though MySQL knows 
dates only from 1000. So from the view of MySQL this is also an invalid date.

Please, null out the column in the model if the cell in the database is also 
NULL (or 0000:00:00). For DATE(TIME) you can do this with this simple check in 
model.tpl:117:

if (! empty($data)) {
    if (! $data instanceof Zend_Date) {
        if (! Zend_Date::isDate($data)) {
            return $this;
        }
        $data = new Zend_Date($data);
    }
…

For further information, see: http://framework.zend.com/issues/browse/ZF-2213

Original comment by szots...@gmail.com on 28 Aug 2012 at 1:56

GoogleCodeExporter commented 8 years ago
I'll handle this one.

Original comment by hadfield...@gmail.com on 17 Aug 2013 at 5:49

GoogleCodeExporter commented 8 years ago
I've pushed up the expand-date-time-functionality branch which should have much 
better date/time handling. If you're still using ZDMG, please give it a try.

Original comment by hadfield...@gmail.com on 18 Aug 2013 at 6:00