You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When declaring a model for a table with a CURRENT_TIMESTAMP set as the default value, the MysqlAdapter throws an exception. Ideally one would not use CURRENT_TIMESTAMP on a database while using the ActiveRecord pattern but we all have the fun of working with legacy databases, especially since this is very new to PHP.
The Exception is thrown from DateTime::__construct =>
>> $a = new DateTime('CURRENT_TIMESTAMP');
Exception (code: 0) got thrown
exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (CURRENT_TIMESTAMP) at position 0 (C): The timezone could not be found in the database' in...
Possible Fix (mimics Rails which just returns nil on a bad time parse):
case self::DATETIME:
case self::DATE:
try {
return ($value instanceof \DateTime) ? $value : new \DateTime($value);
} catch(\Exception $e) {
return null;
}
The text was updated successfully, but these errors were encountered:
When declaring a model for a table with a CURRENT_TIMESTAMP set as the default value, the MysqlAdapter throws an exception. Ideally one would not use CURRENT_TIMESTAMP on a database while using the ActiveRecord pattern but we all have the fun of working with legacy databases, especially since this is very new to PHP.
The Exception is thrown from DateTime::__construct =>
>> $a = new DateTime('CURRENT_TIMESTAMP');
Exception (code: 0) got thrown
exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (CURRENT_TIMESTAMP) at position 0 (C): The timezone could not be found in the database' in...
Possible Fix (mimics Rails which just returns nil on a bad time parse):
The text was updated successfully, but these errors were encountered: