如何将布尔值与准备好的语句放入mysql数据库? [英] How do I put booleans into a mysql database with prepared statements?
本文介绍了如何将布尔值与准备好的语句放入mysql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据 PHP手册,这四种变量类型
- 整数
- double,
- 字符串和
- 斑点.
插入布尔值的最佳方法是什么?
What is the best way to insert a boolean?
推荐答案
无论如何,MySQL并不真正存储布尔值,这是一个把戏.
MySQL doesn't really store booleans anyway, it's a trick.
实际格式为 TINYINT
,我想这是pdo的 integer
.
The actual format is TINYINT
, which is I guess integer
for pdo.
您必须使用 <例如code> intval .
You will have to convert true/false to 1/0, with intval
for example.
这篇关于如何将布尔值与准备好的语句放入mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文