it seems like model is not returning the right value because no matter what is in my database the view says ‘Yes’ and if I try to update a record using the form it always has ‘No’ selected in the drop down list. I’ve tried changing it in the database to look at either 1 or 0 and I get the same results. I’ve tried just echo’ing out $model->isActive and it doesn’t output anything where if you would echo true; it would output a 1.
The only thing I can say is working with the issue is that when I go to save my update it will enter the correct value into the database. It just won’t read anything correctly.
Any ideas or could someone point me in the right direction for documentation for this because I couldn’t find any?
Sorry, I forgot to mention that isActive is a “bit” datatype in mysql. I’m not sure why yii is handling it differently than all of the other data. I’ve even tried casting it into a boolean and I get incorrect results.
Last night when you asked me that I was on my windows desktop and I couldn’t recreate the problem so I kinda thought I was going crazy for a little bit. This morning I’m on my Mac laptop and the problem is back. I using php 5.3.2 on both. Any ideas why it would be different between the two. The values are correct in the database but it only works when I ran it on my windows machine. I’m about to try it on our Linux production server to see if the issue occurs there. Obviously if it occurs there we have a pretty big problem. Any ideas?
Yeah it reacts the same way as my Mac when served up on our linux server. That makes this a bigger problem. Its not a client issue (I didn’t really expect it to be) because I tried it in several browsers on Linux, Mac OS X, and Windows 7. var_dump($model) says that [“isActive”]=> string(1) “” which is odd that its seeing it as a string but it still gives an empty string as its value. Like I said it is saved as a bit in MySQL. Any Ideas?
When its served on my Windows 7 machine (which is working), I have: Apache 2.2.11, PHP 5.3.0, and MySQL 5.1.36
On the Linux Server I’m running CentOS 5.5 (not working), I have: Apache 2.2.3, PHP 5.3.5, and MySQL 5.0.77
Those are the newest compatible versions I could find for CentOS.
I don’t know if that helps but this really boggles me. I suppose MySQL could return the bit differently between the two versions since my Windows machine has a newer version but it doesn’t seem like PHP would be likely since the versions are closer. I don’t even know if the versions matter in this case.
So I figured out what was wrong. It had to do with MySQL. Apparently in the older versions of MySQL bits are thought of differently than newer versions. I resolved the issue by changing the datatype to a tinyint and using 0 as false and anything else as true. It isn’t quite as nice since it could be more than just the two values but it does seem a bit more robust.
I have encountered the same problem. A MySQL column defined as bit (not null default b’0’) works on my local Mac-based environment and fails in the production Linux-based environment.