I am trying to use bitwise operations when quering the DB using a CDbCriteria but am not having any luck; I can’t find anything on the bitwise operators in the ::compare doc. I am looking for something like this:
// only grab users that are not expired.
$criteria = new CDbCriteria;
$criteria->compare('flags','& ' . self::USER_EXPIRED . ' = 0',true);
however this is not working, is there a different function I need to be using?
Have you tried using addCondition() insted of compare()? I imagine something like this should work (though have not tested it):
Out of curiousity: why do you represent information like this in bits? You could use a dedicated column (expired) with enum values (‘yes’, ‘no’), and your code would be a lot more readable and maintainable.