devorye
devorye

Reputation: 303

How to filter column according to it's name in yii2?

I have boolean value in the database and in my GridView I'm trying to filter it according to the name, not id.

I did that in the other column and it worked, but somehow, this column does not. Could someone explain me what I'm doing wrong? Thanks for any help.

        $query->andFilterWhere(['like', 'customer_name', $this->customer_name])
        ->andFilterWhere(['like', 'item.name', $this->item_id])
        ->andFilterWhere(['like', 'sign', $this->sign])
        ->andFilterWhere(['like', 'customer_surname', $this->customer_surname])
        ->andFilterWhere(['like', 'customer_phone', $this->customer_phone])
        ->andFilterWhere(['like', 'customer_email', $this->customer_email])
        ->andFilterWhere(['like', 'code', $this->code])
        ->andFilterWhere(['like', 'comment', $this->comment]);

I did that for item.name, which is from different database table and it worked. I need to do the same to the sign column, that it would be filtering according to Approved or Denied, not by id's. How to do that?

Upvotes: 0

Views: 291

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133370

If you are using a boolen values you should not use a like operator but and equal operator

 ->andFilterWhere(['=', 'sign', $this->sign])

Upvotes: 1

Related Questions