我是 Laravel 新手并使用以下查询,
DB::table("rates as rate")
->select("rate.category")
->where(DB::Raw("STR_TO_DATE(CONCAT( start_day, '/', start_month, '/', start_year ) ,'%d/%m/%Y' )"), ">=", '"'.$InFormat.'"')
->where(DB::Raw("STR_TO_DATE(CONCAT( end_day, '/', end_month, '/', end_year ) ,'%d/%m/%Y' )"), "<=", '"'.$OutFormat.'"')
->where("rate.name", "=", $name)
->whereNull("rate.deleted_at")->get();
此查询未在 Laravel 中运行,但是当我使用 DB::getQueryLog() 获取查询并在 mysql 中运行时,它工作正常。
我认为日期是问题所在。请帮助我。
问候, 雷卡
最佳答案
我认为这是因为您的配置数据库的严格模式
是true
。将字段设置为false
。
你会在
中找到它config/database.php > connections > mysql > strict
关于mysql - Laravel 查询失败但在 Mysql 中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56691024/