Mysql tinyint(1) as boolean and CRUD

Hi,

I've a Mysql DB and thera are tables with tinyint(1) fields (mysql uses this to store boolean values).

When I do CRUD command for these tables, the view and model recognise the field like "numerical" and not boolean. How can i do yiic recognise this field as boolean.

Thanks!!

The code generated by crud is meant to be a good start for you. It still requires your change to fix things like you said. The type tinyint(1) is NOT recognized as a boolean as you know it allows more values than boolean.

Guys, scaffolding is not the problem. BOOL and BOOLEAN are synonyms for TINYINT. It would make sense in MysqlColumnSchema to map tinyint to boolean rather than integer. When I create a column as "boolean" in the DDL, it shows as tinyint(1) in Mysql.

Also it would be nice not to have to hack around Yii with stuff like this:

    if (isset($model->tableSchema))


				if ($model->tableSchema->columns[$attribute]->dbType == 'text')


					$method = 'textarea';


				elseif ($model->tableSchema->columns[$attribute]->dbType == 'tinyint(1)')


					$method = 'checkbox';


				else

David F

It would be better if these suggestions will be entered as issues: http://code.google.com/p/yii/issues/list

Thanks.

As Qiang already explained it’s realy NOT good to map tinyint to boolean…

I use for example tinyInt for fields that holds values from 1-9… so mapping to bool i not an option here…

Can I just ask where this little snippet of code goes to override the scaffolded forms please? Thanks