Search code examples
yii2bit-manipulationbitwise-or

How to use bitwise in Yii2


How can I use bitwise operators in Yii2?

| bitwise OR
& bitwise AND
~ bitwise NOT
! boolean NOT

If we have a query like this:

SELECT a_int_value | b_int_value  
FROM bitwise;  

or how to use bitwise in 'andFilterWhere'

$query->andFilterWhere(['|', 'a_int_value', $this->b_int_value]);

don't work.


Solution

  • You could use also filterCompare

    $query->andFilterCompare('a_int_value', $this->b_int_value, '|');
    

    http://www.yiiframework.com/doc-2.0/guide-db-query-builder.html#filter-conditions