The three endpoints the driver app calls for its wallet built their queries by interpolating the driver id straight into SQL. Anything the app sent went into the statement, and these run against the payments database. They also matched only status = 'Finished'. The current ride pipeline writes 'completed', so a driver's completed rides, pending payouts and weekly earnings all read as zero regardless of how much they had driven — which is what the wallet errors in the admin error log are sitting next to. getAllPayment.php, driverStatistic.php and getCountRide.php now bind the id and match either spelling. Verified no interpolated identifier remains and every rewritten condition is balanced. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
31 lines
674 B
PHP
31 lines
674 B
PHP
<?php
|
|
include "../../connect.php";
|
|
$driver_id = filterRequest("driver_id");
|
|
|
|
$sql = "SELECT
|
|
COUNT(id) AS count
|
|
FROM
|
|
`ride`
|
|
WHERE
|
|
LOWER(`ride`.`status`) IN ('finished','completed')
|
|
AND driver_id = :driver_id
|
|
AND created_at >= CURDATE();
|
|
";
|
|
// كان المعرّف يُدمج في نص الاستعلام مباشرةً — حقن SQL.
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->bindValue(':driver_id', $driver_id);
|
|
$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");
|
|
}
|
|
?>
|