有人可以帮助我将这种雄辩的查询转换为SQL查询,因为我正在尝试研究这段代码。而且我很难理解这段代码是什么,因为我是雄辩的新手,但是我对SQL有一定的经验。
$checkInDate = date("d-m-Y", strtotime($request->start_date));
$checkOutDate = date("d-m-Y", strtotime($request->end_date));
$availableRooms = $this->_availablerooms->from('availableRoom as r')
->selectRaw('*,r.roomDoorNum, r.isAvailable, rt.title as roomType,res.roomReservedID')
->join('roomtype as rt','rt.roomTypeID','=','r.roomTypeID')
->leftjoin('roomReserved as rr','rr.roomID','=','r.roomID')
->leftjoin('reservation as res','res.roomReservedID','=', DB::raw('rr.roomReservedID AND (res.reservationDate BETWEEN '."$checkInDate".' AND ' ."$checkOutDate". ' OR res.expiryDate BETWEEN '."$checkInDate".' AND ' ."$checkOutDate".')' ))
->get();
return $availableRooms;
答案 0 :(得分:0)
没有人真的可以为您做到这一点。明天,您可能需要其他查询才能进入和探索。所以我的建议是安装 https://github.com/barryvdh/laravel-debugbar此程序包,它将负责将雄辩的查询转换为原始查询。