f_user_admin is a TINYINT(4) field in my mySQL database. The table has three records. f_user_admin has a value of 1 for the first record and a value of 2 for the other two records.
If you look at the attached image, you’ll see that the first column displays the correct values from the database. The seconds column should display “Yes” for a value of 1, and “No” for a value of 0. However, as you can see by the image, it always displays “No”.
The ternary part looks fine. I was going to suggest a datatype difference, but you’re using “==”, so you should be fine. What bothers me is the fact that both columns have the same name. The second column is really a computed field. Try changing the name and see if the same problem exists.
I tried changing the name as you suggested, but the problem persists. Before posting in the forum, I had also tried using gettype($data->f_user_admin) as the value, and that returns nothing, which probably means that it’s not recognizing a data type for the variable. This doesn’t make sense since, if I just put $data->f_user_admin as the value, it works (as it does in column 1 of the attached file in my second post). I also tried changing the data type in mySQL from tinyint(4) to int(11), just in case, but it didn’t work.
When I started playing around with expressions last week, I did have quotes around the expression, and that worked great for CGridView. However, when I tried using the same format for an expression in a value for a CDetailView, it would print the expression, literally, on the screen. You can see my post on [post=‘91990’]that topic here[/post]. Someone suggested that I remove the quotes around the expression. I thought it worked at first, but only know am I realizing that it was not printing the correct value on the screen.
Anyway, this fixes the issue for the CGridView, but now I have to figure out how to get it to work for CDetailView. If you can help, let me know [post=‘91990’]here[/post].