久久久久久久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())
主站蜘蛛池模板: 国产精品久久久久久久久久久久冷 | 亚洲欧美日韩在线 | 国产精品视频一区二区三区四区国 | 97在线观视频免费观看 | 在线观看 亚洲 | 在线高清免费观看视频 | 亚洲视频 欧美视频 | 天堂男人av | 人人玩人人添人人澡欧美 | 一级黄a| 福利片一区二区 | 国产午夜在线 | 国产乱码精品1区2区3区 | 欧美日产国产成人免费图片 | 亚洲欧美中文日韩在线v日本 | 欧美日韩一卡二卡 | 免费看一级毛片 | 婷婷福利 | 久久精品国产久精国产 | 欧美激情久久久 | 亚洲视频在线免费观看 | 亚洲激情网站 | 精品久久国产 | 一区二区三区免费 | 免费亚洲视频 | 久久九九99 | www.狠狠干| 国产免费一区二区 | 亚洲免费在线视频 | 精品一区二区三区四区五区 | 国产在线色| 日韩精品久久一区二区三区 | 欧美福利| 成人综合视频在线观看 | 国产在线中文字幕 | 色天天综合 | yiren22综合网成人 | 国产精品久久久久久久久免费相片 | 涩涩片影院 | 日本一区二区三区在线观看 | 人操人免费视频 |