Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 1
    +1 for the typecasting comment. To add on to this when working with programming languages avoid using lazy programming techniques in favor of consistency. Use identical operators instead of just equals. In the case of PHP if( $var == "" ) will be true for 0, false, null, undefined, and "". to test all of the values it is often best to use if( true === empty( $var ) ) as it will avoid the undefined errors as well. You should also validate the data type you are working with if( is_int( $var ) && $var === 0 ) or typecast it to force it into being a specific data type (int) $var for the task. Commented Jan 17, 2014 at 1:35
  • @Thor is this true for MySQL to the same extent it is true for MSSQL? I am migrating a new application that has not gone into production yet from MSSQL to MySQL. I'm not using PHP but rather converting C# over to Java 8. Given that Java is a strongly typed language I am not worried about type handling ... just all the bit flags that would move from one byte for up to 8 flags to 1 byte each flag given TINYINT(1). Do you know of any documentation on this topic for MySQL? Commented Feb 2, 2016 at 20:29
  • 1
    @Thor Doing some deeper research it is clear what the answer should be. Change does happen and we have seen improvements in this handling. Know your language that will be in the Application Layer / Data Access Layer and know your libraries support. I am using Java currently and BIT(1) is the recommended choice at this time for libraries like Hybernate and use of JDBC. Here is the URL [See table 5.2]: dev.mysql.com/doc/connector-j/en/… Commented Feb 3, 2016 at 11:43
  • 1
    prove with a resource link that 8 bit(1) columns take the same byte... I've searched for a while and nowhere have I found it... Commented Dec 30, 2020 at 18:48
  • i think this is actually not true in practice (isam) Commented Feb 2, 2024 at 22:33