|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
lerxstrulz Smarty n00b
Joined: 05 Nov 2011 Posts: 3
|
Posted: Sat Feb 18, 2012 7:59 pm Post subject: Weird boolean issue |
|
|
Hi All,
Newbie to Smarty and have a weird issue. I'm using Smarty with CodeIgniter 2.1 where I retrieve a database record as an associative array that contains boolean fields and pass it to the Smarty renderer. The value of the field is actually null, but it evaluates to TRUE in my Smarty template (and I just upgraded to 3.1.7 to see if that was the issue).
I put some debug code in the template (results below):
{{if $profile.vacation}} EXISTS {{/if}}<br>
{{if $profile.vacation == null}}NULL{{/if}}<br>
{{if $profile.vacation == true}} TRUE {{/if}}<br>
{{if $profile.vacation == 1}} 1 {{/if}}<br>
{{if $profile.vacation == false}} FALSE {{/if}}<br>
{{if $profile.vacation == 0}} 0 {{/if}}<br>
and this is what I get:
EXISTS
TRUE
0
So even though the value is NULL, it evaluates to NOT NULL, TRUE and 0? I even tried
{{if isset($profile.vacation) and $profile.vacation}} and it still evaluates to TRUE, but it is null!
Anyone have any ideas?
Thanks! |
|
Back to top |
|
lerxstrulz Smarty n00b
Joined: 05 Nov 2011 Posts: 3
|
Posted: Sun Feb 19, 2012 1:57 am Post subject: |
|
|
Figured it out. Was using bit instead of boolean type field in mySQL db. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|