To have boolean type in Postgres for PHP

怎甘沉沦 提交于 2020-01-12 19:16:11

问题


I can't believe that the following statement seems to be still true

So, I switched to integers and 0 or 1 works fine, but it is
stupid, that the database system has boolean variables of a smaller
size, but I should use integers for boolean values!

How do you use boolean datatype with Postgres / PHP?

In other words,

Is the only way to use 1 for true and 0 for false in getting the kind of the boolean datatype?


回答1:


Using 1 and 0 is a very sensible and portable way to represent boolean values. Any difference in size between and int and a native boolean type is really going to make little or no difference to your application's performance, or the KB size of your database.



来源:https://stackoverflow.com/questions/1314869/to-have-boolean-type-in-postgres-for-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!