The field adopted is tinyint, should be a 0 or 1 only. This same line shows correct in laravel, a 0 (zero). However in cakephp using the query builder the field is blank.
$connection = ConnectionManager::get('default');
$query = $connection->execute('SELECT * FROM dc_dogs')->fetchAll('obj');
Correct results are given.
So in querybuilder the developers manipulated the way results are returned instead of letting mysql just return natural as is results. Makes no sense.
If null is stored then null should be returned, but if 0 (zero) is stored then 0 should be returned, ditto for 1 (one). What gives anyone the right to hack up mysql returned results? What is wrong with letting itself return what is actually stored, then the view code can be formatted as needed.
By the way that is how other very popular and good frameworks do things.
I would be scared to find out what other data is not returned correctly. Why imagine just letting PDO and MYSQL do their thing, what a World it would be.
So to make sure I understand, is this correct?
A Mysql querybuilder class was written by someone to return wrong results
MySql wasnt ‘written by someone to return wrong results’ they had to make compromise either support type (bool) that this database doesnt support or make users implement hacks to support boolean
I am aware of the way mysql and bool works, my point it should be up to the developer to handle such things, as an example I know if dealing with a checkbox to do something like:
My point also is sometimes you want to see that 0 returned, you only want to see a blank if null is actually stored. There should have been a setting for this.
Works correctly and displays the 0 (zero). Doesn’t it make you wonder if the cake developers were so concerned about boolean returns, then why does native database return the actual value stored.
Sorry as I can be, this having querybuilder different from database just doesn’t make sense.
I know cakephp is open source and free so I can’t really complain. But I even created an issue and it was just dismissed basically.
But the bottom line is if a 0 is stored you should retrieve a 0. And if it’s a checkbox, then the developer should know how to handle a checkbox as displayed above.
EDIT: I just looked at formhelper it shows
Blockquote
boolean, tinyint(1)
checkbox
Which a checkbox I do display on user form, but the admin page I just display a 0 or 1 in the listview (table view). No need to have a checkbox displayed there. I suppose I could, may even play around with that.