CakePHP的打印布尔 [英] cakephp print a boolean

查看:145
本文介绍了CakePHP的打印布尔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CakePHP初学者的问题,它驱使我疯了,我试了很多,但在CakePHP不能得到这个工作。
我想打印火车站附近的如果布尔设置。
该数据库具有现场训练位(1)进行时

Beginners question in cakePHP, it drives me mad, I tried so much but can't get this working in cakePHP. I want to print 'Train station nearby' if the boolean is set. The database has the field 'train' bit(1) when doing a

<?php echo h($property['Property']['train']); ?>

这表明1,但它为0的数据库,为什么打印1,而不是0

it shows 1 but in the database it is 0, WHY is it printing 1 instead of 0

<?php if($property['Property']['train'] == true ) echo 'Train station nearby'; ?>

这个输出工作所有的时间,但当然这不是真的!
请人,这是什么做的其实是有点(1)现场还是我做错了什么。请记住我是一个初学者,我也尝试了很多的例子PHP与布尔值,只是想不通,为什么它不CakePHP中为我工作。
感谢您寻找到这一点。

This output works all the time, but of course it is not true! Anyone please, is this something to do with the fact it is a bit(1) field or am I doing something wrong. Please keep in mind I am a beginner, and I did try a lot of php examples with booleans, but just can't work out why it is not working for me in cakePHP. Thanks for looking into this.

推荐答案

如果你正在使用MySQL使用 TINYINT(1)为其模拟为布尔值。字段

If you are using mysql use tinyint(1) for the field which is emulated as boolean.

这篇关于CakePHP的打印布尔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆