人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

業(yè)界新聞動態(tài)、技術前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      PHP中Laravel 關聯(lián)查詢返回錯誤id的解決方法

PHP中Laravel 關聯(lián)查詢返回錯誤id的解決方法

標簽: 發(fā)布日期:2017-04-01 00:00:00 267

在 Laravel Eloquent 中使用 join 關聯(lián)查詢,如果兩張表有名稱相同的字段,如 id,那么它的值會默認被后來的同名字段重寫,返回不是期望的結果。例如以下關聯(lián)查詢:

PHP

$priority = Priority::rightJoin('touch', 'priorities.touch_id', '=', 'touch.id')
 ->where('priorities.type', 1)
 ->orderBy('priorities.total_score', 'desc')
 ->orderBy('touch.created_at', 'desc')
 ->get();