Search code examples
phptestingcakephpfixturescakephp-2.x

How to define decimal data type for fixtures in Cakephp2.x?


I am creating a fixture for testing in cakephp2.x. I want to define the field type as a decimal, which is straightforward. However, I want to define it specifically with DECIMAL(6,4), but cannot figure out how to set the digits.

I can't find it in the cookbook either: https://book.cakephp.org/2/en/development/testing.html

Any help would be appreciated!


Solution

  • You can specify both in the column definitions length option, like so:

    public $fields = array(
        'column_name' => array(
            'type' => 'decimal',
            'length' => '6,4',
            'null' => false,
        ),
        // ...
    );