Tuesday, August 20, 2013

CakePHP 2.3.8 and MySQL's YEAR Type

Hi all,

I am currently working on a project that needs to handle annual reports.  I was considering using MySQL's YEAR(4) data type, but was unsure how well CakePHP supported it, so I decided to test it out with bake.  I made a table with the following schema:

+-------+------------------+------+-----+---------+----------------+
| Field | Type             | Null | Key | Default | Extra          |
+-------+------------------+------+-----+---------+----------------+
| id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| year  | year(4)          | NO   |     | NULL    |                |
+-------+------------------+------+-----+---------+----------------+ 

And then ran bake to get my basic model, controller, and view.  Surprisingly, Cake defaulted to displaying the year field as a textarea on the add form.  I am puzzled by this.  Is there something I can do to get Cake to handle this field more gracefully out of the box?  Or am I better off just using an INT datatype?

Thanks,
-Will 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: