4 回答
TA贡献1802条经验 获得超5个赞
在命名空间中添加
use DB;
然后在方法中添加表名,
public function downloadZip(Request $request)
{
$job_id = $request->job_id;
$filename = DB::table('table_name')->where('job_id',$job_id)->get()->pluck('filename')->toArray();
}
TA贡献1794条经验 获得超8个赞
在命名空间中
use DB;
在下载方法中:
public function downloadZip(Request $request)
{
$job_id = $request->job_id;
$filenames = DB::table('analytics_report')->where('job_id',$job_id)->pluck('filename');
}
TA贡献1963条经验 获得超6个赞
您可以使用 DB 类来执行此操作:
public function downloadZip(Request $request)
{
$job_id = $request->job_id;
$filenames = DB::table('analytics_report')->select('filename')
->where('job_id', $job_id)->get()->toArray();
}
或者,如果您已经有analytics_report的模型并假设您的模型是AnalyticsReport,您可以使用:
public function downloadZip(Request $request)
{
$job_id = $request->job_id;
$filenames = AnalyticsReport::select('filename')
->where('job_id', $job_id)->toArray();
}
TA贡献1878条经验 获得超4个赞
使用此查询
public function downloadZip(Request $request)
{
$job_id = $request->job_id;
$file = DB::table('table_name')->where('job_id','=',$job_id)->select('filename')->get()->toArray();
}
- 4 回答
- 0 关注
- 156 浏览
添加回答
举报