Hodges
(Dev)
February 13, 2015, 5:51am
1
Hello:
I’m building a search model and I’m running into a problem with the where syntax. What I need is to be able to filter on various fields but have it set up so that the first WHERE clause is always TRUE. But some reason when I use the "orFilterWhere’ its getting ignored. I understand how to do this in straight SQL but is there a way to do this using Yii?
Thanks.
$query->where("entry_type <> 'M'")
->orFilterWhere(['like', 'lists.description', $search_criteria])
->orFilterWhere(['like','memo',$search_criteria])
->orderBy('tran_date desc');
Hodges
(Dev)
February 13, 2015, 6:01am
2
I figured it out. For anyone else running into this problem you have to do it this way:
$query->filterWhere(['like', 'lists.description', $search_criteria])
->orFilterWhere(['like','memo',$search_criteria])
->andWhere("entry_type <> 'M'")
->orderBy('tran_date desc');
Hello:
I’m building a search model and I’m running into a problem with the where syntax. What I need is to be able to filter on various fields but have it set up so that the first WHERE clause is always TRUE. But some reason when I use the "orFilterWhere’ its getting ignored. I understand how to do this in straight SQL but is there a way to do this using Yii?
Thanks.
$query->where("entry_type <> 'M'")
->orFilterWhere(['like', 'lists.description', $search_criteria])
->orFilterWhere(['like','memo',$search_criteria])
->orderBy('tran_date desc');