Files
Siro/backend/ride/rides/getTripCountByCaptain.php
2026-06-09 08:40:31 +03:00

23 lines
546 B
PHP

<?php
require_once __DIR__ . '/../../connect.php';
$driver_id = filterRequest("driver_id");
$sql = "
SELECT COUNT(*) as count
FROM `ride`
WHERE driver_id = :driver_id AND status = 'Finished'
";
$stmt = $con->prepare($sql);
$stmt->bindParam(':driver_id', $driver_id, PDO::PARAM_INT); // أو PARAM_STR حسب نوع الـ ID
$stmt->execute();
if ($stmt->rowCount() > 0) {
$row = $stmt->fetch(PDO::FETCH_ASSOC);
jsonSuccess($row);
} else {
jsonError($message = "No finished ride records found for this driver");
}
?>