字串格式,例如:'status=1'雜湊格式,例如: ['status' => 1, 'type' => 2]
操作符格式,例如:['like', 'name', 'test']
//->andfilterwhere(['between','updated_at',$oldtime, $current])
->andwhere(['between','updated_at',$oldtime, $current])
//->andfilterwhere(['like','name',$name])
->andwhere(['like','name',$name])
//第一種->where(['=', 'status',10])
->andwhere(['like', 'title','yii'])
# where (`status` = 10) and (`title` like '%yii%')
//第二種
->addwhere(['and', 'id=1', 'name=2']);
# where id=1 and name=2
//第三種
->addwhere(['and', 'type=1', ['or', 'id=1', 'id=2']]);
# where type=1 and (id=1 or id=2);
//第四種
->andwhere(['or like','name',['哈哈','苦苦']]);
# where `name` like '%哈哈%' or `name` like '%苦苦%';
//第五種
->addwhere(['or',['like','name','哈哈'],['like','title','苦苦']]);
# where (`status`=1) and ((`name` like '%哈哈%') or (`title` like '%苦苦%'))
Yii2查詢之where條件拼裝
2017 01 22 4282瀏覽記錄 目錄 熟悉yii2的查詢條件後,用active record查詢資料非常方便。以下我們介紹where 方法當中,條件的拼裝方式。yii2用where 方法 當然還有其他方法 來實現條件篩選,語法 public this where condition,para...
Yii2查詢之where條件拼裝
目錄 1語法2雜湊格式 3運算子格式 3.1對比 3.2and 3.3or 3.4not 3.5between和not between 3.6in和not in 3.7like 3.8exists 熟悉yii2的查詢條件後,用active record查詢資料非常方便。以下我們介紹where 方法當...
yii2中的多表查詢
資料庫 classe表 create table classe cid int 11 not null auto increment,cname varchar 10 default null,tid int 11 default null,primary key cid key fk id cla...