Why Table Integer Fields Is Known As String In Rules Created With Gii

Hi,

Expose there is a table with two fields: id(INT) and status(TINYINT)

When creating model with Gii will be create two rule for the attributes:




array('status', 'numerical', 'integerOnly'=>true),

array('id', 'length', 'max'=>10),



Why id considered as string but status as integer?

Are you sure?

run from sql command "DESCRIBE yourtable"

also which is your database ?

Table:

[sql]CREATE TABLE test ( id INT NULL , status INT UNSIGNED NULL );[/sql]

Rules:


    public function rules()

    {

        // NOTE: you should only define rules for those attributes that

        // will receive user inputs.

        return array(

            array('id', 'numerical', 'integerOnly'=>true),

            array('id2', 'length', 'max'=>10),

            // The following rule is used by search().

            // Please remove those attributes that should not be searched.

            array('id, id2', 'safe', 'on'=>'search'),

        );

    }

Int fields with UNSIGNED flag were considered as String.

It is very strange, please re-generate the model by gii (use another php name file) and post entire code,

also what sql do you use? (mysql, sqlserver etc)

Dear friend, i try it several times(with another php file name). but each time the result was same. i use MySQL. Do you try it?

Yes I just try it, You are right!

Something is wrong on fetching table schema, may be a bug of Yii or mysql driver.

The ‘unsigned int’ returns type “string” to Gii generator so


array('status', 'length', 'max'=>10)

generated

check these

http://www.doctrine-project.org/jira/browse/DBAL-394

http://bugs.mysql.com/bug.php?id=52007

but the most important is

So, we need need to fix it manually(The rules generated with Gii).