日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Yii的Where条件

發(fā)布時(shí)間:2024/9/19 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Yii的Where条件 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#標(biāo)準(zhǔn)寫(xiě)法$stat_book_list = BookSaleChangeLog::find() ->select( [ 'book_id','SUM(quantity) AS total_count','SUM(price) AS total_pay_money' ] ) ->andWhere([ 'between','created_time',$time_start,$time_end ]) ->groupBy('book_id')->asArray()->all();$query = Project::find()->where(['dept_id'=>$dept_id])->all();#寫(xiě)完之后一定要加上one()或者是all()#對(duì)比 ['>', 'id', 1] // 生成:id > 1 ['<', 'id', 100] // 生成:id < 100 ['=', 'id', 10] // 生成:id = 10 ['>=', 'id', 1] // 生成:id >= 1 ['<=', 'id', 100] // 生成:id <= 100 ['!=', 'id', 10] // 生成:id != 10#并聯(lián) ['and', 'id' => 1, 'id' => 2] // 生成:id=1 AND id=2 ['and', 'id=1', 'id=2'] // 生成:id=1 AND id=2 ['and', 'type=1', ['or', 'id=1', 'id=2']] // 生成:type=1 AND (id=1 OR id=2)#OR ['or', ['type' => [7, 8, 9]], ['id' => [1, 2, 3]]] // 生成:(type IN (7, 8, 9) OR (id IN (1, 2, 3)))#NOT ['not', ['attribute' => null]] // 生成:NOT (attribute IS NULL)#between ['between', 'id', 1, 10] // 生成:id BETWEEN 1 AND 10 ['not between', 'id', 1, 10] // 生成:id NOT BETWEEN 1 AND 10#IN ['in', 'id', [1, 2, 3]] // 生成:id IN (1, 2, 3) ['id' => [4, 8, 15]] // 生成:id IN (4, 8, 15) ['not in', 'id', [1, 2, 3]] // 生成:id NOT IN (1, 2, 3) ['in', ['id', 'name'], [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar']]] // 生成:(`id`, `name`) IN ((1, 'foo'), (2, 'bar'))#子查詢(xún) #用子查詢(xún)作為IN條件的值 ['in', 'user_id', (new Query())->select('id')->from('users')->where(['active' => 1])]#模糊查詢(xún) ['like', 'name', 'tester'] // 生成:name LIKE '%tester%'['like', 'name', ['test', 'sample']] // 生成:name LIKE '%test%' AND name LIKE '%sample%'['like', 'name', '%tester', false] // 生成:name LIKE '%tester' 這是自定義查詢(xún)方式,要傳入值為false的運(yùn)算數(shù)3,并且自行添加%['or like', 'name', ['test', 'sample']] // 生成:name LIKE '%test%' OR name LIKE '%sample%'['not like', 'name', 'tester'] // 生成:name NOT LIKE '%tester%'['or not like', 'name', ['test', 'sample']] // 生成:name NOT LIKE '%test%' OR name NOT LIKE '%sample%'['exists', (new Query())->select('id')->from('users')->where(['active' => 1])] // 生成:EXISTS (SELECT "id" FROM "users" WHERE "active"=1)

?

總結(jié)

以上是生活随笔為你收集整理的Yii的Where条件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。