0

我试图在 7 天内获得记录的总和。但我得到了上述错误

$today = date('Y-m-d H:i:s');
$week = jobs::Whereraw('DATEDIFF(?,completed_at) <= 7')
             ->setBindings('[$today]')
             ->get();
4

2 回答 2

2

你把它变成了一个字符串?

    ->setBindings('[$today]')

应该

    ->setBindings([$today])

不?

于 2020-06-27T03:51:21.493 回答
2

您的代码将如下所示

$week = jobs::Whereraw('DATEDIFF(?,completed_at) <= 7')
             ->setBindings([$today])
             ->get();

不串它会[$today]

于 2020-06-27T03:55:39.350 回答