Laravel 5.5 whereDate/whereTime不添加引号 [英] Laravel 5.5 whereDate/whereTime not add quotation
本文介绍了Laravel 5.5 whereDate/whereTime不添加引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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).
推荐答案
这似乎是laravel中未将日期括在引号中的可能错误,这导致将Y-m-d视为数学运算.
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'))
成为
schedule_date = 2019-09-10
成为
schedule_date = 2006
这篇关于Laravel 5.5 whereDate/whereTime不添加引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文