= NOW() - INTERVAL :freshSeconds SECOND AND COALESCE(cr.year, 0) > 2000 AND (cr.make NOT LIKE '%دراج%' AND cr.model NOT LIKE '%دراج%') ORDER BY cl.updated_at DESC, ratingDriver DESC LIMIT 5 "; $stmt = $con->prepare($sql); // Bind the new bounding box parameter $stmt->bindValue(':boundingBox', $boundingBoxWKT); $stmt->bindValue(':freshSeconds', $freshSeconds, PDO::PARAM_INT); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); if (!$rows) { printFailure("No car locations found"); exit; } // Decryption and age calculation logic remains the same $fieldsToDecrypt = [ 'phone','email','gender','birthdate', 'first_name','last_name','maritalStatus', 'token','make','car_plate','vin' ]; foreach ($rows as &$row) { foreach ($fieldsToDecrypt as $field) { if (isset($row[$field]) && $row[$field] !== null && $row[$field] !== '') { try { $row[$field] = $encryptionHelper->decryptData($row[$field]); } catch (Exception $e) { $row[$field] = null; } } } if (!empty($row['birthdate'])) { try { $birthdate = new DateTime($row['birthdate']); $today = new DateTime(); $row['age'] = $today->diff($birthdate)->y; } catch (Exception $e) { $row['age'] = null; } } else { $row['age'] = null; } if (isset($row['serverNow'], $row['updated_at'])) { error_log('PHP Now: '.date('Y-m-d H:i:s') .' | MySQL Now: '.$row['serverNow'] .' | updated_at: '.$row['updated_at']); } } unset($row); printSuccess($rows); } catch (PDOException $e) { printFailure("Database error: " . $e->getMessage()); } catch (Throwable $e) { printFailure("Internal error: " . $e->getMessage()); }