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

problem with model

I have a problem when i make a query on database, following the code that i tried run:

Os::count(array("status_id != 5", "group" => "DATE_FORMAT(datafinaliza, '%Y-%m')"));

The error that i received:

Scanning error before 'DATE_FORMAT(data...' when parsing: SELECT DATE_FORMAT(datafinaliza, '%Y-%m'), COUNT(*) AS rowcount FROM [Os] WHERE status_id != 5 GROUP BY [DATE_FORMAT(datafinaliza, '%Y-%m')] (140)

How i can build correct this query? Thanks



33.8k

Try this (I assume datafinaliza is a column):

Os::count([
    "status_id != 5 GROUP BY DATE_FORMAT(datafinaliza, '%Y-%m')"
]);