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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算