We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

MySQL date functions within Model Query

i have written following function inside a model and trying to execute it however it fails for below error any idea ?

return count(User::query() ->where(" DATE(register) >= DATE_SUB( CURDATE() , INTERVAL 30 DAY ) ") ->execute());

Error is

Syntax error, unexpected token INTEGER(30), near to ' DAY ) ', when parsing: SELECT [xx\Models\User].* FROM [xx\Models\User] WHERE register >= DATE_SUB( CURDATE() , INTERVAL 30 DAY ) (126)