PHP Question

How to use 'andFilterWhere' with 'like' for integer fields in Yii2?

I try to make a filter for integer field in mongoDB using


$query->andFilterWhere(['like', 'code', $this->code ]);

This method work fine for String value but for integer value doesn't work. How to use this method for integer fields?

Answer Source

This example helps me to solve my issue:

 if ($this->code)
                '$where' => '/' . $this->code . '/.test(this.code')'