Yii2 Tips 23 : All About Where ActiveQuery
Select * From branches Where status_aktif = 1
1 2 3 |
\common\models\Branches::find() ->where(['status_aktif' => 1]) ->all(); |
Select * From branches Where status_aktif = 1 (Bind Param)
1 2 3 |
\common\models\Branches::find() ->where('status_aktif=:status_aktif',[':status_aktif' => 1]) ->all(); |
Select * From branches Where created_date <= now
1 2 3 |
\common\models\Branches::find() ->where(['<=', 'created_date', date('Y-m-d H:i:s')]) ->all(); |
Menampilkan nilai branches yang statusnya diterima (12), ditolak (13), pending (14)
1 2 3 |
\common\models\Branches::find() ->where(['IN', 'status', [StatusFlag::DITERIMA, StatusFlag::DITOLAK, StatusFlag::PENDING]]) ->all(); |
Select * From branches Where name like ‘%%’
1 2 3 |
\common\models\Branches::find() ->where(['like', 'name', $this->name]) ->all(); |