gpt4 book ai didi

php - laravel 中的查询返回空响应

转载 作者:行者123 更新时间:2023-11-29 05:01:32 25 4
gpt4 key购买 nike

我想在 laravel 中使用 leftJoin 从我的数据库中检索数据。我的约会表中有两个表名 usersappointments 有一个字段名 doctor_id 包含与 users 中的 id 相关的医生 id .两者的 id 值相同。如果列 id 值在users 表将 appointments 表中的列约会值与 where 子句匹配,其中 patient_id = $patientID。但是当我执行查询时,它返回空响应。

代码

$patientID = $request->patientID;
$prevAppointments = DB::table('appointments')
->leftJoin('users', 'appointments.doctor_id', '=', 'users.id')
->select(
'users.first_name',
'users.last_name',
'appointments.appointment_date',
'appointments.status'
)
->where('appointments.patient_id', $patientID)
->get();
return($prevAppointments);

用户表

user table

约会表

appointments table

最佳答案

试试这个 -

$patientID = $request->patientID;
$prevAppointments = DB::table('appointments')
->leftJoin('users', 'appointments.doctor_id', '=', 'users.id')
->select('users.first_name','users.last_name','appointments.patient_id', 'appointments.appointment_date','appointments.status')
->where('appointments.patient_id',$patientID)
->get();
return($prevAppointments);

关于php - laravel 中的查询返回空响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58041616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com