doucheng7534
2017-10-05 05:13
浏览 159
已采纳

连接查询以合并laravel中的三个表

I want to join project table with department table based on department_string_id and join users table with project_owner_id in project table with users table aceid for the condition project.project_owner_id=users.aceid

desired query (working fine)
 select p.*,d.department_head_aceid from project as p inner join department as d on p.department_string_id=d.department_string_id inner join users as u on p.project_owner_id=u.aceid where u.id='4' 

Laravel query

 $approver_id_roles=DB::table('project')
         ->join('department', 'project.department_string_id', '=', 'department.department_string_id')->join('users','project.project_owner_id','=','users.aceid')
         ->where('project.project_owner_id','=','users.aceid')
         ->select('department.department_head_aceid')->get();

caught below error

TokenMismatchException in VerifyCsrfToken.php line 68:

What I did wrong here

图片转代码服务由CSDN问答提供 功能建议

我想基于department_string_id将项目表与department表连接,并使用users表将项目表中的project_owner_id与users表连接起来 条件project.project_owner_id = users.aceid

 所需查询(正常工作)
选择p。*,d.department_head_aceid从项目作为p内部联接部门作为d 在p.department_string_id = d.department_string_id内部加入用户作为你在p.project_owner_id = u.aceid,其中u.id ='4'
   
 
 

Laravel查询

  $ approver_id_roles = DB :: table('project')
  - > join('department','project.department_string_id','=','department.department_string_id'  ) - > join('users','project.project_owner_id','=','users.aceid')
  - > where('project.project_owner_id','=','users.aceid')\  n  - > select('department.department_head_aceid') - > get(); 
   
 
 

捕捉到以下错误

TokenMismatchExcept VerifyCsrfToken.php第68行中的离子:

我在这里做错了什么

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • drol55885602 2017-10-05 05:19
    已采纳

    To avoid CSRF attack we want add token in form. Laravel token

    <input type="hidden" name="_token" value="{{ csrf_token() }}">
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题