I have setup a BIT(64) field in MYSQL.
I can populate this field OK converting the flags "0000000000000000000000000000000000000000000000000000000000000101", but when the data is returned in a query it is represented as "\x0\x0\x0\x0\x0\x0\x0\x5" and I can't find any hints online how to convert this back to flags....
I've pulled out what little hair I had left, threw my arms in the air and post this plea for HELP!!
I know you are going to say 'why?', but I'm not looking for criticism, just an answer...
p.s. I'm a mainframe COBOL programmer and all this php stuff is a bit foreign...
Processing BIT data "\x0\x0\x0\x0\x0\x0\x0\x5"
Moderator: General Moderators
Re: Processing BIT data "\x0\x0\x0\x0\x0\x0\x0\x5"
[sql] SELECT bin(fieldName) FROM tableName ... [/sql]
Re: Processing BIT data "\x0\x0\x0\x0\x0\x0\x0\x5"
Thanks, I'll have a go at that, but as that will require me to change all the SELECT statements from "SELECT *" to "SELECT bin(fieldName), fieldName2, ...." I was really looking for a post-select coding solution.
Re: Processing BIT data "\x0\x0\x0\x0\x0\x0\x0\x5"
Coding "SELECT *, bin(fieldName) as flags .." worked well. I'll just propagate that wherever needed.
Thanks muchly...
Thanks muchly...
Re: Processing BIT data "\x0\x0\x0\x0\x0\x0\x0\x5"
That would really complicate things, especially if you use 32bit php (because you're using 64bit bit field). Anyway, just in case you'd ever need it: you would need to unpack data to two unsigned longs (note that byte order is machine-dependent) and then either convert them to bit string using decbin or use them as ints and perform bit arithmetics on them yourself.gmckay wrote:I was really looking for a post-select coding solution.