Reputation: 1570
I have a column in database table active
which should return whether user has confirmed mail or not. It is tinyint(1) and if it is set 0 and I test it strictly against FALSE operator doesn't return TRUE. I use ORM to communicate with database.
This is set in MySQL database:
active tinyint(1) Yes 0
if ($user->active === FALSE) // returns FALSE
if ($user->active === '0') // returns TRUE
I've been searching in API for solution and in Database class there was already tinyint datatype.
Do I have to use == instead of === or there is something else I could do?
Upvotes: 0
Views: 529
Reputation: 7042
To keep things consistent, casting db data to PHP equivalents was removed since 3.0, meaning you're right - no strict comparison :)
What you can do if you really want it is overwrite ORM::_load_values()
combined with ORM::list_columns()
to cast to 'right' data types (that is - if you're staying with the MySQL driver because moving to PDO will break things).
Upvotes: 2