Phinx: How to declare tinyint(1)

Created on 25 Jan 2016  路  4Comments  路  Source: cakephp/phinx

Hi i am trying to create a column with type tinyint and limit 1 using the following but cant get to create a column with limit 1, it always defaults to 4

->addColumn('AppleMusic', 'integer', array('limit'=>  \Phinx\Db\Adapter\MysqlAdapter::INT_TINY ))

and if i try the integer with limit 1 like below

->addColumn('AppleMusic', 'integer', array('limit'=> 1))

it keeps the type integer and sets limit 1

any link to the documentation although i searched a lot, or similar example would be helpful
regards,
Omer Aslam

Most helpful comment

i need to declare the column type boolean and limit =1 and it will automatically set it to tinyint(1)
regards,
Omer Aslam

All 4 comments

i need to declare the column type boolean and limit =1 and it will automatically set it to tinyint(1)
regards,
Omer Aslam

Hi! Try to use boolean type. It is the same as TINYINT(1):
->addColumn('AppleMusic', 'boolean')

Hey guys
I know CakePhp interprets tinyint as boolean if set to limit (1).
However I would like to save a tinyint non-boolean data type, where the values would always be (0 || 1 || -1) and would not want to get many records as int (for storage sake reasons). How do I set as tinyint(2) using phinx?

Tip: run dump and check the lock file
The output reveals sth like

tinyinteger";s:6:"length";i:2;

which I think makes clear what you are looking for.

Docs here can probably be improved a bit.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amcoho picture amcoho  路  4Comments

Divi picture Divi  路  5Comments

nickcv-ln picture nickcv-ln  路  5Comments

resgef picture resgef  路  5Comments

J-Fricke picture J-Fricke  路  3Comments