【发布时间】:2021-09-27 00:42:13
【问题描述】:
我在使用 Laravel 执行程序时不断收到此错误:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') < Now()' at line 1 (SQL: select count(*) as aggregate from `house` where `isoccupied` = 0 and (currentdatasync + INTERVAL '1 DAY') < Now())
我在控制器中的功能是:
public function view()
{
$failed = DB::table('house')
->where('isoccupied', 0)
->whereRaw("(currentdatasync + INTERVAL '1 DAY') < Now()")
->count('*');
return view('admin.dashboard')->with('failed', $failed);
}
我试过用
return view('admin.dashboard')->with(compact($failed));
但是还是不行。
以前有人经历过吗?
【问题讨论】:
-
不要引用持续时间
+ INTERVAL 1 DAY应该可以正常工作