Laravel 5.5 whereDate/whereTime not add quotation

假如想象 提交于 2020-01-06 09:09:12

问题


Appointment::whereDate('schedule_date', '=', date('Y-m-d'))
    ->whereTime('time_from', ' <= ', date('H:i:s'))
    ->whereTime('time_to', ' <= ', date('H:i:s', strtotime('+1 hour')))
    ->get();

When this code is running on the production server, there's no response. Perhaps it's for quotation? But how can I add this? I mean quotation (single/double).


回答1:


This appears to be a possible bug in laravel not enclosing the date in quotes, this results in it treating the Y-m-d as a maths operation.

whereDate('schedule_date', '=', date('Y-m-d'))

becomes

schedule_date = 2019-09-10

becomes

schedule_date = 2006



来源:https://stackoverflow.com/questions/54846061/laravel-5-5-wheredate-wheretime-not-add-quotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!