KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Bit type in the database #652

Closed Eugene opened this topic on on Feb 5, 2019 - 2 comments

Eugene commented on Feb 5, 2019

Hi, my database developer used bit(1) type for some columns in mysql database (he used it for all columns with boolean meaning). It looks like koolreport interprets these columns as type int and I get nothing even the value in the column is b'1'

I did a small test

this is my test table

this is the test code:

$this->src('quinos')
            ->query('select testbit, testbool from testtest limit 1')
            ->pipe($this->dataStore('test'))->requestDataSending();
        var_dump($this->dataStore('test')->meta());
        var_dump($this->dataStore('test')->data());

And the output:

array(1) { ["columns"]=> array(2) { ["testbit"]=> array(1) { ["type"]=> string(6) "number" } ["testbool"]=> array(1) { ["type"]=> string(7) "unknown" } } }

array(1) { [0]=> array(2) { ["testbit"]=> int(0) ["testbool"]=> string(1) "1" } }

How can I get the correct value?

KoolReport commented on Feb 6, 2019

You try:

select CAST(testbit AS INT) AS intvalue ...
Eugene commented on Feb 6, 2019

Thank you. It helped.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

None