gpt4 book ai didi

php - 加入 DB::raw() laravel 4

转载 作者:行者123 更新时间:2023-11-29 11:36:29 26 4
gpt4 key购买 nike

我的数据库中有 3 个表:

reponse[id,nomRep,#envoi_id]
envoi[id,#projet_id,#quest_id]
projet[id,nomProjet]

我想要做的是使用下面的代码获取我的项目的名称:

 $days = Input::get('days', 7);
$range = \Carbon\Carbon::now()->subDays($days);
$chartt = DB::table('reponse')
->where('created_at', '>=', $range)
->groupBy('value')

->remember(1440)
->get([
DB::raw('envoi_id as nomProjet')// here where i want to get the name of my project,
DB::raw('etatSatisfaction as value')

]);

return $chartt;

请问有什么帮助吗?

最佳答案

这是我自己找到的答案,也许有人需要它:

  DB::raw(' (SELECT p.nom FROM projet p,ligneenvoi l WHERE rep.ligneenvoi_id=l.id AND l.projet_id=p.id) AS nomProjet ') ,

关于php - 加入 DB::raw() laravel 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36501740/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com