<?php
include "../../connect.php";
$passenger_id = filterRequest("passenger_id");

$sql = "SELECT
    `id`,
    `passenger_id`,
    `balance`,
    `created_at`,
    `updated_at`,
    (
    SELECT
        SUM(balance)
    FROM
        passengerWallet
    WHERE
        passenger_id = '$passenger_id'
) AS total
FROM
    `passengerWallet`
WHERE
    passenger_id = '$passenger_id'
GROUP BY
    `passenger_id`,
    `id`;";
$stmt = $con->prepare($sql);
$stmt->execute();

if ($stmt->rowCount() > 0) {
    // Fetch the record
    $row = $stmt->fetchAll(PDO::FETCH_ASSOC);

    printSuccess( $row);
    
}
    else{
    // Print a failure message
    printFailure($message = "No wallet record found");
}
?>