相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
PHP中Laravel 關(guān)聯(lián)查詢返回錯誤id的解決方法
在 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();