Cakephp: while inserting tinyint field. Getting only “0” or “1”

后端 未结 1 1248
情书的邮戳
情书的邮戳 2021-01-22 21:42

I\'m a noob in cakephp. Working on an opensource project. The issue is:

When I\'m inserting a value for a certain table ( \"is_adjusted\" (tinyint)), the my php code exe

相关标签:
1条回答
  • 2021-01-22 22:17

    This is by CakePHP's design. CakePHP always see tinyint(1) as boolean hence it will always convert your value to true/false hence the 1/0.

    To overcome this issue, use tinyint(2) instead for your column type. Remember to clear your model cache!


    CakePHP data type documentation:
    http://book.cakephp.org/3.0/en/orm/database-basics.html#data-types

    Blog post about this:
    http://blog.room34.com/archives/2649

    Similar Q&A:
    CakePHP and tinyint as boolean

    0 讨论(0)
提交回复
热议问题