i wanna write some query statement like this statement in YII2.0
this below code is wrong but i wanna write it like this syntax
Thank you
i wanna write some query statement like this statement in YII2.0
this below code is wrong but i wanna write it like this syntax
Thank you
Probably you don’t need to modify “search” method of your PensSearch.
I guess it should already have something like the following:
$query->andFilterWhere('PEN_MODEL', $this->PEN_MODEL);
It will do the following:
[list=1]
[*] If $this->PEN_MODEL is empty, it will do nothing.
[*] If $this->PEN_MODEL is a scalar value, it will add " WHERE PEN_MODEL
= ‘something’" to the query.
[*] If $this->PEN_MODEL is an array, it will add " WHERE PEN_MODEL
in (A,B,C,…X)" to the query.
[/list]
Take a look at these items in the API reference.
andFilterWhere()
where()
[EDIT]
Is ‘PEN_MODEL’ a string? Then it’s a bit different.
// $query->andFilterWhere('like', 'PEN_MODEL', $this->PEN_MODEL);
$query->andFilterWhere('or like', 'PEN_MODEL', $this->PEN_MODEL);
It’s work, Thank you so much