While messing with a new website that I am working on, I find a slightly annoying issue with CakePHP that doesn't seem to be documented anywhere. I was trying to store a thumb up/down record in a tinyint(1) field. A thumb up would have a value of 1 and a thumb down would have a value of -1. CakePHP was kindly(sarcism) converting my -1 to a 1 every time.

It appears that CakePHP assumes that all tinyint(1) fields are actually boolean fields. Therefore, if anything other than false is set in the field, it will store a 1 as the value.

So, if you notice that all your negative numbers that are one digit in size are being changed to 1, try changing your field to an tinyint(2).
Views  115 Comments  0
Filed under: CakePHP, Web Development
Add Comment
View Chris Thompson's profile on LinkedIn
Loading...