Yii2 query / query builder: how to use OR condition

Yii2 query / query builder: how to use OR condition You can use some thing like this: $third_res_count=CustomerReservedTimeslots::find() ->select([‘COUNT(timeslot_id) AS cnt’]) ->where([ ‘test_date’ => $today_date, ‘confirmed’ => ‘1’, ]) ->andWhere([‘>’, ‘third_user_id’, ‘0’]) ->andFilterWhere([ ‘or’, [‘like’, ‘status’, ‘checked in’], [‘like’, ‘status’, ‘Waiting for check in’], ]) ->one();

YII2 DB Count Results query

YII2 DB count results query Simple in the controller or view file add do this: $count=MODEL::find()   ->select([‘COUNT(id) AS cnt’])   ->where([   ‘field1’ => $value1, ])-> andWhere([‘>’, ‘field2’, $value2]) ->one()->cnt; And in the model of the table add before this line: public static function tableName() Add public $cnt; like below: public $cnt; public static… Continue reading YII2 DB Count Results query

Yii, update record (update query) method

Update By Primary KeyModel::model()->updateByPk($Model->id,array(“status”=>’ok’)); Update All RowsModel::model()->updateAll(array(‘user’=>”$userid”,’date’=>$currenttime),”status=>’ok'”);