= DATE(NOW()) - INTERVAL 6 DAY GROUP BY DATE(r.created_at) ORDER BY DATE(r.created_at) ASC "; $stmt = $con->prepare($sql); $stmt->bindParam(':driver_id', $driver_id, PDO::PARAM_INT); $stmt->execute(); if ($stmt->rowCount() > 0) { $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); jsonSuccess($rows); } else { jsonSuccess([]); } } catch (PDOException $e) { // Return empty but log error error_log("getWeeklyAggregate Error: " . $e->getMessage()); jsonError("Database error occurred"); } ?>