久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Laravel Eloquent Union 查詢

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
本文介紹了Laravel Eloquent Union 查詢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

所以我有以下查詢:

$a = Model::where('code', '=', $code)
    ->where('col_a', '=' , 1)
    ->orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout'))

$b = Model::where('code', '=', $code)
    ->where('col_b', '=' , 1)
    ->orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout'))

$a->union($b)->get();

當我先orderBy()"然后聯合時,不會發生排序.

No sorting is happening when I 'orderBy()' first and then union.

當我單獨查詢 '$a' 或 '$b' 時,'orderBy()' 工作正常.

When I do query '$a' or '$b' individually the 'orderBy()' works fine.

當我按照以下方式進行時,orderBy()"會作為一個整體發生.

When I do it in the following way 'orderBy()' happens as a whole.

$a->union($b)
    ->orderBy(DB::raw('FIELD(layout, "normal", "split", "flip", "double-faced", "") ASC, layout'))
    ->get();

我怎樣才能使orderBy()"分別適用于每個人,然后將結果合并回來?看起來它應該可以工作.

How can I make it so the 'orderBy()' applies for each individually and then union the results back? It seems like it should work.

如果有人能提供一種方法來做到這一點,即使它是普通的 MySQL,我也會選擇你的作為答案,因為我認為 Eloquent 可能存在錯誤.

If anyone can provide a way to do this, even if it's normal MySQL, I will choose yours as the answer as I think there may be a bug with Eloquent.

推薦答案

嘗試以下操作:

$a = Model::where('code', '=', $code)
->where('col_a', '=' , 1);

$b = Model::where('code', '=', $code)->where('col_b', '=' , 1)
->union($a)
->get();

$result = $b;

這篇關于Laravel Eloquent Union 查詢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

使用 json_encode對數組加密后,輸出的漢字部分是空的,怎么回事了? 各位大俠們,有沒有好的解決方案? 急救 解決辦法 你原始的數據是gbk的,這是不能被 json_encode 所接受的 json_encod
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數)
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內容必須是實現 __toString()、“boolean和“boolean的字符串或對象.移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 国产精品国产三级国产a | 国产综合视频 | 日韩视频在线一区 | 日韩电影免费在线观看中文字幕 | 瑞克和莫蒂第五季在线观看 | 日韩在线免费电影 | 亚洲中午字幕 | 中文字幕在线欧美 | 久草视频观看 | 国产伦精品一区二区三区照片91 | 亚洲三级视频 | 国产97人人超碰caoprom | 久久久毛片 | 久久国产精品久久久久久 | 国产精品电影在线观看 | 免费在线观看一区二区三区 | 久久小视频 | 国产欧美在线 | 日韩电影一区二区三区 | 国产综合网站 | 欧美日韩a | 视频一区欧美 | 成人亚洲一区 | 精品无码久久久久久国产 | 波多野结衣一区二区三区在线观看 | 中文字幕日韩欧美一区二区三区 | 亚洲午夜av久久乱码 | 天天躁日日躁狠狠躁白人 | 久久精品国产一区二区电影 | av激情影院| 在线中文字幕av | 欧美一卡二卡在线观看 | www.国产一区| 欧美午夜影院 | 97成人在线 | 三级黄色片在线观看 | 久久精品国产一区 | 久久精品中文 | 精品久久99| 毛片一级网站 | 亚洲欧美综合精品久久成人 |