Wordpress Database Class - MySQL Type Bit Wordpress Database Class - MySQL Type Bit wordpress wordpress

Wordpress Database Class - MySQL Type Bit


Check this answer out:https://stackoverflow.com/a/5323169/794897

"When you select data from a MySQL database using PHP the datatype will always be converted to a string."

You can either do:

if ($data[0]->Sold === "1") { ...if ($data[0]->Sold === "0") { 

or type cast the variable, e.g.

$Sold = (int) $data[0]->Sold;if ($Sold === 1) { ...if ($Sold === 0) { 


For me the solution was to use ord function: http://us1.php.net/manual/en/function.ord.php

Edit

Yet the behavior seems to differ depending on the server. On Arch Linux with MariaDB 10.0.14 and Ubuntu with MySQL 5.5.37-0ubuntu0.13.10.1 wpdb returns good old "0" or "1" strings, not the problematic bit-strings, which happen on CentOS 6.4 MySQL 5.1.73