Dynamic query where clause in yii
- By Preneesh AV --
- 04-Oct-2018 --
- 75 Comments
To add where clause dynamically we can use the below method:
$res = propertyDetail::find()->joinWith('propertyImages');$res = $res->where(['pkPropertyIDPrimary'=>1])->all();//Another example : $products = Products::find(); if(!empty($search->name)){ $products= $products ->andwhere(['LIKE', 'ProductName', $search->name,]);} $products= $products->all();
