Level 3
@eskiesirius Maybe it duration should be between quotations ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This is my database structure:
id | duration | used_at | status
1 | 1 | 2022-01-22 02:40:11 | used
and my query is this:
public function scopeExpiringSubscription($query)
{
return $query
->withoutGlobalScopes()
->whereRaw("DATE_ADD(used_at, INTERVAL duration MONTH) < NOW()")
->where('status', self::USED);
}
but i got this error
SQLSTATE[HY000]: General error: 1 near "duration": syntax error (SQL: select * from "vouchers" where DATE_ADD(used_at, INTERVAL duration MONTH) < NOW() and "status" = used)
Please or to participate in this conversation.