I have a keyword "example query" and I like to query like this
SELECT * FROM project WHERE
(FLAG=1 and STATUS=1)
and(NAMA_PROJECT like '%example query%' or DESCRIPTION_PROJECT like '%example query%' or NAMA_PROJECT like '%example%' or NAMA_PROJECT like '%query%')
ORDER BY WAKTU_POST;
I already try this but it give me the query I didn't want.
$query=Project::find()->where(['FLAG'=>1,'STATUS'=>1])
->andFilterWhere(['like','NAMA_PROJECT',$q])
->andFilterWhere(['like','DESCRIPTION_PROJECT',$q]);
$words=\yii\helpers\BaseStringHelper::explode($q,$delimiter=' ');
foreach($words as $word){
$query->orWhere(['like','NAMA_PROJECT',$word]);
}
Is it possible to have a loop inside where condition?