Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Database Schemas Don't Map Date Column Types By Default?

$
0
0
I have a class based on CActiveRecord that processes columns in the model and needs to do slightly different things depending on the datatype of the column, specifically for date / datetime columns. It checks the column datatype by executing $this->getTableSchema()->getColumn($column_name)->type. Unfortunately, I noticed all the date/datetime columns from the table have their types returned as "string" rather than "date" or "datetime."

In looking at CMysqlColumnSchema extractType()method it only maps MySQL data types to string or numeric types, and maps all date types to string. Is there a reason for not mapping db date types to php date types? Is there a simple way in my model class I can override the returned schema values for certain columns so my base CActiveRecord class can tell which columns are date types?

Viewing all articles
Browse latest Browse all 18717

Trending Articles