dshm8998473 2019-01-18 12:24
浏览 55
已采纳

获取未在Laravel中设置为外键的行的数据

I want to get data of rows from a table that are not set as foreign keys in the related table. Please guide me on this in Laravel. I have used this but it's returning all data

$pages = DB::table('client_requests')
                ->leftJoin('bid_requests', 'client_requests.id', '=', 'bid_requests.client_request_id')
                ->select('client_requests.*')
                ->orderBy('created_at', 'DESC')
                ->paginate(20);
  • 写回答

1条回答 默认 最新

  • dpauxqt1281 2019-01-18 16:45
    关注

    Thanks every one for your support. The problem was solved. This is the solution. It will be helpful for anyone with same issue. To get rows of data that is not set as foreign key in related table this is the way to get it in laravel.

    $pages = DB::table('client_requests')
                    ->leftJoin('bid_requests', 'client_requests.id', '=', 'bid_requests.client_request_id')
                    ->select('client_requests.*')
                    ->where('bid_requests.client_request_id','=',null)
                    ->orderBy('created_at', 'DESC')
                    ->get();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 软件定义网络mininet和onos控制器问题
  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。