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

Count group by with specific month using find

Is it possible I make a simple query to count how many records I have in a determined period of time like a Year, month or day

help me, count group by product_added with specific month

$parameters['group'] = " DATE_FORMAT(product_added, '%Y%m')"; //date format : 2014-10-09 06:35:04
$group = \App\Models\Products::count($parameters);

like sql

GROUP BY YEAR(product_added), MONTH(product_added)  

or

GROUP BY DATE_FORMAT(product_added, '%Y%m');


33.8k

Create a string var $where that will have a string that will have more or less conditions. That conditions will be different if you pass one or more periods. Later, do $group = \App\Models\Products::count($where);