dongxingdu9594 2019-04-12 06:32
浏览 75
已采纳

我在laravel查询语言中遇到错误

Missing argument 1 for Illuminate\Database\Connection::table()

I am passing the argument here in the table function. I am getting this error on every function of the database which I am using.

It is working fine when I create the object of the model and then use the function table().

This is the code which I am using.

return DB::table('crop_growth')
         ->leftJoin('farmer_details', 'crop_growth.farmer_id', '=', 'farmer_details.id')
         ->select('crop_growth.id', 'crop_growth.remind_after', 'crop_growth.reason', 'crop_growth.is_read', 'farmer_details.name', 'farmer_details.phone')
         ->where('crop_growth.emp_id', $empId)
         ->where('crop_growth.remind_after', '!=', null)
         ->orderBy('crop_growth.is_read', 'ASC')
         ->orderBy('crop_growth.remind_after', 'ASC')
         ->get();
  • 写回答

1条回答 默认 最新

  • dongpeiwei8589 2019-04-12 07:11
    关注

    You need to add the table method in your query then you are set.

    DB::connection('mysql / <or whatever mane you called it>')->table('crop_growth')-> rest of your query.
    

    if you still have the error you can set the database in your table field.

    table('<database>.crop_growth')
    

    although i will set a test select first then the left join then the actual select but this is OK to.

    Good luck

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题