[categorie_id => сумма] */ public function getMonthActualByCategory(int $user_id, int $year, int $month): array { $sql = "SELECT categorie_id, SUM(summa * COALESCE(rate_to_rub, 1)) AS s FROM $this->table WHERE user_id = :user_id AND categorie_id IS NOT NULL AND YEAR(date) = :year AND MONTH(date) = :month GROUP BY categorie_id"; $stmt = $this->pdo->prepare($sql); $stmt->execute(['user_id' => $user_id, 'year' => $year, 'month' => $month]); $result = []; foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $result[(int)$row['categorie_id']] = (float)$row['s']; } return $result; } }