I would like to store a simple date in my table. I have a date field “dob” in my table as DATETIME, because sqlite doesn’t have a Date type. When I bake the table, cake assumes I want the field to be a time: “@property \Cake\I18n\Time $dob”
Can I tell cake to treat that field as a date field instead of a time field?
"@property \Cake\I18n\Date $dob"
Seems like I should be able to define the data types of each property in the Entity class, but I don’t see how.
I know I can format the date each time I use it, and specify how its handled on all the forms, but I’m lazy and I’d like cake to do all the hard work me.
use Cake\Database\Schema\Table as Schema;
class WidgetsTable extends Table
protected function _initializeSchema(Schema $schema)
standard types are:
That almost works… That method name seems a little misleading, I didn’t try that method because I assumed the adding a custom type would be different than simply specifying a standard type.
I used that method to change the data type to date; so now cake correctly assumes that I want a date editor on the add/edit forms. However, when I try to save the data, cake crashes with any meaningful errors.
So I have migrated the data to MySQL database, which works fine. But after several years away from cakephp I was disappointed to see that it still doesn’t play nicely with SQLite.