Whenever i create a new record of this model and set cargo_repicare or cargo_replegal to either 1 or 0 (should be “interpreted” as true or false as i understand) the data gets saved correctly in the DB. But when i try to show this data (update an existing Cargo Model for example, or even doing a query with QueryBuilder) these attributes are always true. I can see that the values are sent correctly via Yii::$app->request->post(), i’ve also checked the value after performing $model->save() and it shows “1” or “0” based on the value of a radio button i select as it should. But for some reason, when retrieving this data to display it in my form or other places it always shows “1” (true).
I have read some topics about this like this, and the issue seems to have been fixed via PR’s, but i still can’t make it work.
Thanks for your answer, Roberto. You’re correct, i’m using the BIT data type in order to save space, i’ll take a look on other options a little bit more. But I’ll further look upon the option you provided as well.
You need to check your RDBS. If you have only ONE BIT column then you are correct, but I think that you get the benefit when you have MORE than one. Either MySQL and/or SQLserver, combines the BIT columns and stores them together up to 8. So 8 BIT columns is equal to TINYINT(1). 8+1 = TINYINT(2), 16+1 = TINYINT(3), etc.