国产精品成人VA在线观看,亚洲日韩在线中文字幕综合,亚洲AV电影天堂男人的天堂,久久人人爽人人爽人人av东京热

News新聞

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

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

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

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

在 Laravel Eloquent 中使用 join 關(guān)聯(lián)查詢,如果兩張表有名稱相同的字段,如 id,那么它的值會默認(rèn)被后來的同名字段重寫,返回不是期望的結(jié)果。例如以下關(guān)聯(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();