On Jul 16, 6:19 pm, Dérico Filho <[email protected]> wrote:
> Hi
>
> Some of you might feel bugged when trying to access an TINYINT(1)
> field in mysql with values different from 0 or 1.
>
> It happens that CakePHP thinks TINYINT(1) is BOOLEAN.

Look at the definition of what a BOOLEAN is:
http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html

e.g. http://pastebin.com/9QF6Ecun

> Therefore, 0 is
> 0/False and anything else but zero is 1/TRUE.
>
> If it ever happens to you, you have two options.
>
> First, you may change the field type to INT(1) -- which will wok
> although it might change the way MySQL handle data.

Personally I use TINYINT(2).

>
> Second, you may dike out the lines:
>                 if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
>                         return 'boolean';
>                 }
> AND
>                 'boolean' => array('name' => 'tinyint', 'limit' => '1')
>
> From cake/libs/model/datasources/dbo/dbo_mysql*.php

Your fix just breaks things the other way around - what if you /do/
have a TINYINT(1) which you want to have yes/no stored in it.

hth,

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to