Is your bitnum
column defined as bit(50)
?
My guess is that the value gets inserted properly into DB. Everything after that requires some testing.
Do you use some query when you say "phpMyAdmin and PHP outputs for some reason is this: 00001100110011100000111000001101100011000000111000
"?
I tried to use the PhpMyAdmin a little but it displays bit
colums as empty, NULL
or whatever. Even using PhpMyAdmin's SQL query interface didn't reveal the values as they should appear. Try some other DB management software. I use Sequel Pro and it shows the bit
values as they are entered into DB. (Maybe PhpMyAdmin does it too somehow, I just don't know how.)
As for PHP engine, well... See my interesting question. There might be a bug in some PHP version or not. At least a query similar to this should retrieve a correct value.
SELECT (bitnum + 0) AS my_multiple_bit FROM features
This was my RTM moment of that question: If "+ 0" is not used the value of a bit(1) column is treated as binary string.
(Also remember that PHP version can cause it's own problems.)
Maybe also BIN(bitnum)
works as (bitnum + 0)
. Try and test with one more PHP engine versions. If everything works, well... then everything works.
BTW. Is there some specific reason in using bit(50)
column? What's wrong with int
or char
? (I used bit(1)
as a boolean true
/false
just for the kick of it. tinyint(1)
is my other alternative fo booleans. I didn't read this whole article but maybe bit
columns aren't the best choice for column type in MySQL.)