DECLARE loop_date DATETIME; // изменяемая дата в цикле
DECLARE end_date DATETIME; // конечная дата
SET loop_date = DATE_ADD(end_date, INTERVAL -90 DAY);
WHILE DATE(loop_date) <= DATE(end_date) DO
INSERT INTO `times` (`id`, `date`, `time`) VALUES (NULL, loop_date, '08:00');
...
INSERT INTO `times` (`id`, `date`, `time`) VALUES (NULL, loop_date, '17:00');
SET loop_date = DATE_ADD(loop_date, INTERVAL 1 DAY);
END WHILE
function allpackets_func($database, $date_from, $date_to)
{
return $database->sum('flow_table', 'packets', ["stamp[<>]" => [$date_from, $date_to]]);
}