Yii Framework Forum: Mysql tinyint(1) as boolean and CRUD - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Mysql tinyint(1) as boolean and CRUD Rate Topic: -----

#1 User is offline   rubeng 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 21-November 08

Posted 26 November 2008 - 06:18 AM

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!!
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,871
  • Joined: 04-October 08
  • Location:DC, USA

Posted 26 November 2008 - 07:45 AM

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.
0

#3 User is offline   David F 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 26-January 10

Posted 28 March 2011 - 04:42 AM

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


View Postqiang, on 26 November 2008 - 07:45 AM, said:

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.

0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,312
  • Joined: 17-January 09
  • Location:Russia

Posted 29 March 2011 - 05:19 PM

David F
It would be better if these suggestions will be entered as issues: http://code.google.c...yii/issues/list

Thanks.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#5 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,336
  • Joined: 12-October 09
  • Location:Croatia

Posted 30 March 2011 - 01:43 AM

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...
Find more about me.... btw. Do you know your WAN IP?
0

#6 User is offline   AhmetS 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 01-May 13

Posted 18 July 2013 - 09:47 AM

View PostDavid F, on 28 March 2011 - 04:42 AM, said:

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


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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users